package com.coolcsn;
public class Person implements Introducable{
protected String name;
protected int age;
private static int counter = 0;
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setAge(int age) {
if (age <= 120) {
this.age = age;
}
}
public int getAge() {
return age;
}
public double getBalance() {
return age * 42.5;
}
public static int getCounter() {
return counter;
}
// Overloading
// Working horse
public Person(String name, int age) {
this.name = name;
this.age = age;
counter++;
}
public Person(){
this("Default", 0);
// name = "Deafult";
// age = 0;
}
public Person(int age, String name) {
this(name, age);
// this.name = name;
// this.age = age;
}
public void introduceYourSelf() {
System.out.printf("My name is %1$s. I am %2$d years old! And my balnce is %3$f \n", name, age, getBalance());
}
public static double getNationalIncome()
{
return counter * 10000;
}
}
Comments