Browse Source

conversion

master
esoe 2 years ago
parent
commit
75ddf84c0c
  1. 21
      country/src/main/java/ru/molokoin/Area.java
  2. 24
      country/src/main/java/ru/molokoin/Conversion.java
  3. 2
      country/src/main/java/ru/molokoin/Map.java
  4. BIN
      country/target/classes/ru/molokoin/Area.class
  5. BIN
      country/target/classes/ru/molokoin/Conversion.class
  6. BIN
      country/target/classes/ru/molokoin/Country.class
  7. BIN
      country/target/classes/ru/molokoin/Map.class

21
country/src/main/java/ru/molokoin/Area.java

@ -12,10 +12,10 @@ public class Area { @@ -12,10 +12,10 @@ public class Area {
//Area (Object name, Object population, Object square){}
}
Area(String name, int population, int square){
Area(Object name, int population, int square){
init(name, population, square);
}
public void init(String name, int population, int square){
public void init(Object name, int population, int square){
setName(name);
setPopulation(population);
setSquare(square);
@ -28,20 +28,29 @@ public class Area { @@ -28,20 +28,29 @@ public class Area {
/**
* @param name the name to set
*/
public void setName(String name) {
public void setName(Object name) {
//преобразование Object
try {
if(name == "")throw new IllegalArgumentException(name);
if (name == null) throw new NullPointerException(getName());
} catch (Exception e) {
System.out.println("Наименвание не должно быть пустым. ");
e.printStackTrace();
this.name = "";
}
try {
if((String)name == "")throw new IllegalArgumentException((String)name);
} catch (IllegalArgumentException e) {
System.out.println("Наименвание не должно быть пустым. ");
e.printStackTrace();
this.name = name;
this.name = "";
}
this.name = name;
if (name != null) this.name = (String)name;
}
/**
* @param population the population to set
*/
public void setPopulation(int population) {
//население не может быть отрицательным
if (population < 0) throw new IllegalArgumentException("Население не может быть отрицательным ...");
this.population = population;

24
country/src/main/java/ru/molokoin/Conversion.java

@ -0,0 +1,24 @@ @@ -0,0 +1,24 @@
package ru.molokoin;
public class Conversion {
/**
* Проверяем содержимое объекта.
*
* @param object
* @return
*/
public static Object checknull(Object object){
Object result = new Object();
if (object == null)throw new NullPointerException("Обнаружено пустое поле данных ...");
return (Object)result;
}
public static int toint(Object object){
String s = (String) object;
return Integer.parseInt(s);
}
public static String toString(Object object){
return "";
}
}

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

@ -28,7 +28,7 @@ public class Map { @@ -28,7 +28,7 @@ public class Map {
}
}
public static void main(String[] args) {
System.out.println("App.main()");
System.out.println("Map.main()");
Map terra = new Map();
terra.initDefaults();
printAll(terra.map);

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

Binary file not shown.

BIN
country/target/classes/ru/molokoin/Conversion.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