From 732b4d945ac88d717b2c0f46ce73604f07e62c28 Mon Sep 17 00:00:00 2001 From: esoe Date: Thu, 13 Oct 2022 16:46:53 +0300 Subject: [PATCH] qq --- country/ru/molokoin/Area.java | 3 +++ country/ru/molokoin/Country.java | 6 ++++++ country/ru/molokoin/Map.java | 11 ++++++++--- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/country/ru/molokoin/Area.java b/country/ru/molokoin/Area.java index 3334977..0c41d0f 100644 --- a/country/ru/molokoin/Area.java +++ b/country/ru/molokoin/Area.java @@ -11,6 +11,9 @@ public class Area { setPopulation(population); setSquare(square); } + public void print(){ + System.out.println("name: " + name + "; population:" + population + "; square: " + square); + } /** * @param name the name to set diff --git a/country/ru/molokoin/Country.java b/country/ru/molokoin/Country.java index d0a4582..a678d3e 100644 --- a/country/ru/molokoin/Country.java +++ b/country/ru/molokoin/Country.java @@ -4,12 +4,18 @@ public class Country extends Area{ private Area capital; Country(String name, int population, int square, String capitalName, int capitalPopulation, int capitalSquare){ + init(name, population, square, capitalName, capitalPopulation, capitalSquare); + } + public Country() { + } + public void init(String name, int population, int square, String capitalName, int capitalPopulation, int capitalSquare){ setCapital(capitalName, capitalPopulation, capitalSquare); setName(name); setPopulation(population); setSquare(square); } + /** * @param сapital the сapital to set */ diff --git a/country/ru/molokoin/Map.java b/country/ru/molokoin/Map.java index 3071780..96d4838 100644 --- a/country/ru/molokoin/Map.java +++ b/country/ru/molokoin/Map.java @@ -1,12 +1,17 @@ package country.ru.molokoin; public class Map { - private Country[] map;// = new Country[5]; + private Country[] map = new Country[5]; public void initDefaults(){ - map = new Country[5]; - map[0].setName("Russia"); + map[0] = new Country(); + map[0].init("Russia", 17100000, 146700000, "Moscow", 12600000, 0); } public static void main(String[] args) { System.out.println("App.main()"); + Map m = new Map(); + m.initDefaults(); + m.map[0].print(); + m.map[0].getCapital().print(); + } }