Advertisement
Kur23

DWAFGHFGJH

May 16th, 2022
927
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Person {
  2. private String name;
  3. private String address;
  4. public Person() {
  5. }
  6. public Person(String name, String address) {
  7. this.name = name;
  8. this.address = address;
  9. }
  10. public String getName() {
  11. return name;
  12. }
  13. public void setName(String name) {
  14. this.name = name;
  15. }
  16. public String getAddress() {
  17. return address;
  18. }
  19. public void setAddress(String address) {
  20. this.address = address;
  21. }
  22. @Override
  23. public String toString() {
  24. return "Name: " + this.getName()
  25. + "\nAddress: " + this.getAddress();
  26. }
  27. }
  28. Student Class:
  29. package com.company;
  30. public class Student extends Person{
  31. private String school;
  32. private double grade;
  33. public Student() {
  34. super();
  35. }
  36. public Student(String name, String address, String school, double grade)
  37. {
  38. super(name, address);
  39. this.school = school;
  40. this.grade = grade;
  41. }
  42. public String getSchool() {
  43. return school;
  44. }
  45. public void setSchool(String school) {
  46. this.school = school;
  47. }
  48. public double getGrade() {
  49. return grade;
  50. }
  51. public void setGrade(double grade) {
  52. this.grade = grade;
  53. }
  54. @Override
  55. public String toString() {
  56. return super.toString()
  57. + "\nSchool: " + this.getSchool()
  58. + "\nGrade: " + this.getGrade();
  59. }
  60. }
  61.  
Advertisement
RAW Paste Data Copied
Advertisement