Advertisement
wingman007

Java2014OOP_Person

Dec 6th, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6.  
  7. package myworld;
  8.  
  9. /**
  10.  *
  11.  * @author fmi
  12.  */
  13. public abstract class Person implements Introducable {
  14.     protected String name;
  15.     protected int age;
  16.    
  17.     public static final double PI = 3.14;  // constant
  18.    
  19.     public static String nationality = "Bulgarian";
  20.    
  21.     public String getName() {
  22.         return name;
  23.     }
  24.    
  25.     public void setName(String name) {
  26.         this.name = name;
  27.     }
  28.    
  29.     public int getAge() {
  30.         return age;
  31.     }
  32.    
  33.     public void setAge(int age) {
  34.         this.age = age;
  35.     }  
  36.    
  37.     public Person(String name, int age){
  38.         this.name = name;
  39.         this.age = age;
  40.     }
  41.    
  42.     public Person() {
  43.         this("Anonymous", 0);
  44.     }
  45.    
  46.     @Override
  47.     public void introduceYorSelf()
  48.     {
  49.         System.out.println("I am a person! My name is " + name + ". I am " + age + " years old! I am " + nationality);
  50.     }
  51.    
  52.     // public abstract void doTest();
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement