You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package country.ru.molokoin;
|
|
|
|
|
|
|
|
public class Area {
|
|
|
|
private String name;
|
|
|
|
private int population;
|
|
|
|
private int square;
|
|
|
|
|
|
|
|
Area(){}
|
|
|
|
Area(String name, int population, int square){
|
|
|
|
init(name, population, square);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void init(String name, int population, int square){
|
|
|
|
setName(name);
|
|
|
|
setPopulation(population);
|
|
|
|
setSquare(square);
|
|
|
|
}
|
|
|
|
public void print(){
|
|
|
|
System.out.println("name: " + name + "; population:" + population + "; square: " + square);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param name the name to set
|
|
|
|
*/
|
|
|
|
public void setName(String name) {
|
|
|
|
this.name = name;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param population the population to set
|
|
|
|
*/
|
|
|
|
public void setPopulation(int population) {
|
|
|
|
this.population = population;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param square the square to set
|
|
|
|
*/
|
|
|
|
public void setSquare(int square) {
|
|
|
|
if (square < 0) throw new IllegalArgumentException("площадь не может быть отрицательной ...");
|
|
|
|
this.square = square;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the name
|
|
|
|
*/
|
|
|
|
public String getName() {
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return the population
|
|
|
|
*/
|
|
|
|
public int getPopulation() {
|
|
|
|
return population;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return the square
|
|
|
|
*/
|
|
|
|
public int getSquare() {
|
|
|
|
return square;
|
|
|
|
}
|
|
|
|
}
|