Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. public class Person extends Student {
  2. private String name;
  3. private int DoB = 0;
  4.  
  5. public Person(String name, int DoB) {
  6. this.name = name;
  7. this.DoB = DoB;
  8. }
  9.  
  10. public String getName() {
  11. return name;
  12. }
  13.  
  14. public void setName(String name) {
  15. this.name = name;
  16. }
  17.  
  18. public int getDoB() {
  19. return DoB;
  20. }
  21.  
  22. public void setDoB(int DoB) {
  23. this.DoB = DoB;
  24. }
  25.  
  26. public String toString() {
  27. return "Person [name=" + this.name + ", DateOfBirth=" + this.DoB + "]";
  28. }
  29.  
  30. public void printState() {
  31. System.out.println(toString());
  32. }
  33.  
  34. public static void main(String[] args) {
  35. Person p = new Person("Danil", 1995);
  36. System.out.println(p.toString());
  37.  
  38. }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement