esoe
2 years ago
8 changed files with 59 additions and 62 deletions
@ -1,44 +0,0 @@
@@ -1,44 +0,0 @@
|
||||
package country.ru.molokoin; |
||||
|
||||
public class Country extends Area{ |
||||
private Area capital; |
||||
|
||||
Country(String name, int population, int square, String capitalName, int capitalPopulation, int capitalSquare){ |
||||
this.init(name, population, square); |
||||
this.capital = new Area(); |
||||
getCapital().init(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 |
||||
*/ |
||||
public void setCapital(String name, int population, int square) { |
||||
this.capital = new Area(name, population, square); |
||||
} |
||||
|
||||
/** |
||||
* @return the сapital |
||||
*/ |
||||
public Area getCapital() { |
||||
return capital; |
||||
} |
||||
|
||||
public static void main(String[] args) { |
||||
System.out.println("Country.main()"); |
||||
|
||||
} |
||||
} |
@ -1,17 +0,0 @@
@@ -1,17 +0,0 @@
|
||||
package country.ru.molokoin; |
||||
|
||||
public class Map { |
||||
private Country[] map = new Country[5]; |
||||
public void initDefaults(){ |
||||
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(); |
||||
|
||||
} |
||||
} |
@ -1,4 +1,4 @@
@@ -1,4 +1,4 @@
|
||||
package country.ru.molokoin; |
||||
package ru.molokoin; |
||||
|
||||
public class Area { |
||||
private String name; |
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
package ru.molokoin; |
||||
|
||||
public class Country extends Area{ |
||||
private Area capital; |
||||
|
||||
public Country() { |
||||
} |
||||
Country(String name, int population, int square, String capitalName, int capitalPopulation, int capitalSquare){ |
||||
this.init(name, population, square); |
||||
setCapital(new Area(capitalName, capitalPopulation, capitalSquare)); |
||||
} |
||||
|
||||
/** |
||||
* @param сapital the сapital to set |
||||
*/ |
||||
public void setCapital(Area capital) { |
||||
this.capital = capital; |
||||
} |
||||
|
||||
/** |
||||
* @return the сapital |
||||
*/ |
||||
public Area getCapital() { |
||||
return capital; |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
package ru.molokoin; |
||||
|
||||
public class Map { |
||||
private Country[] map = new Country[5]; |
||||
public void initDefaults(){ |
||||
System.out.println("map.length: " + map.length + " ..."); |
||||
//заполняем поля данными
|
||||
map[0] = new Country("Russia", 17100000, 146700000, "Moscow", 12600000, 0); |
||||
map[1] = new Country("Russia", 17100000, 146700000, "Moscow", 12600000, 0); |
||||
map[2] = new Country("Russia", 17100000, 146700000, "Moscow", 12600000, 0); |
||||
map[3] = new Country("Russia", 17100000, 146700000, "Moscow", 12600000, 0); |
||||
map[4] = new Country("Russia", 17100000, 146700000, "Moscow", 12600000, 0); |
||||
} |
||||
public static void print(Country[] map){ |
||||
System.out.println("Количество государств, данные о которых включены в terra: " + map.length); |
||||
int i = 0; |
||||
while (i < map.length) { |
||||
System.out.println("-------------------------------------------"); |
||||
map[i].print(); |
||||
map[i].getCapital().print(); |
||||
System.out.println("-------------------------------------------"); |
||||
i++; |
||||
} |
||||
|
||||
} |
||||
public static void main(String[] args) { |
||||
System.out.println("App.main()"); |
||||
Map terra = new Map(); |
||||
terra.initDefaults(); |
||||
print(terra.map); |
||||
} |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue