esoe 2 years ago
parent
commit
732b4d945a
  1. 3
      country/ru/molokoin/Area.java
  2. 6
      country/ru/molokoin/Country.java
  3. 11
      country/ru/molokoin/Map.java

3
country/ru/molokoin/Area.java

@ -11,6 +11,9 @@ public class Area {
setPopulation(population); setPopulation(population);
setSquare(square); setSquare(square);
} }
public void print(){
System.out.println("name: " + name + "; population:" + population + "; square: " + square);
}
/** /**
* @param name the name to set * @param name the name to set

6
country/ru/molokoin/Country.java

@ -4,12 +4,18 @@ public class Country extends Area{
private Area capital; private Area capital;
Country(String name, int population, int square, String capitalName, int capitalPopulation, int capitalSquare){ 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); setCapital(capitalName, capitalPopulation, capitalSquare);
setName(name); setName(name);
setPopulation(population); setPopulation(population);
setSquare(square); setSquare(square);
} }
/** /**
* @param сapital the сapital to set * @param сapital the сapital to set
*/ */

11
country/ru/molokoin/Map.java

@ -1,12 +1,17 @@
package country.ru.molokoin; package country.ru.molokoin;
public class Map { public class Map {
private Country[] map;// = new Country[5]; private Country[] map = new Country[5];
public void initDefaults(){ public void initDefaults(){
map = new Country[5]; map[0] = new Country();
map[0].setName("Russia"); map[0].init("Russia", 17100000, 146700000, "Moscow", 12600000, 0);
} }
public static void main(String[] args) { public static void main(String[] args) {
System.out.println("App.main()"); System.out.println("App.main()");
Map m = new Map();
m.initDefaults();
m.map[0].print();
m.map[0].getCapital().print();
} }
} }

Loading…
Cancel
Save