esoe 2 years ago
parent
commit
7118437c62
  1. 44
      country/ru/molokoin/Country.java
  2. 17
      country/ru/molokoin/Map.java
  3. 2
      country/src/main/java/ru/molokoin/Area.java
  4. 26
      country/src/main/java/ru/molokoin/Country.java
  5. 32
      country/src/main/java/ru/molokoin/Map.java
  6. BIN
      country/target/classes/ru/molokoin/Area.class
  7. BIN
      country/target/classes/ru/molokoin/Country.class
  8. BIN
      country/target/classes/ru/molokoin/Map.class

44
country/ru/molokoin/Country.java

@ -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()");
}
}

17
country/ru/molokoin/Map.java

@ -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();
}
}

2
country/ru/molokoin/Area.java → country/src/main/java/ru/molokoin/Area.java

@ -1,4 +1,4 @@
package country.ru.molokoin; package ru.molokoin;
public class Area { public class Area {
private String name; private String name;

26
country/src/main/java/ru/molokoin/Country.java

@ -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;
}
}

32
country/src/main/java/ru/molokoin/Map.java

@ -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);
}
}

BIN
country/target/classes/ru/molokoin/Area.class

Binary file not shown.

BIN
country/target/classes/ru/molokoin/Country.class

Binary file not shown.

BIN
country/target/classes/ru/molokoin/Map.class

Binary file not shown.
Loading…
Cancel
Save