Write a superclass called ؛Person (as shown in the class diagram), which contains: • Two instance variables name (String) and address (String). • Two constructors: a (no-argument) constructor that initializes the name to "Ahmed" and address to “Gaza”, and a constructor that initializes the name and address to the given values. • Getter and setter for all the instance variables. • A toString() method that returns "A Person with name of xxx and address of yyy Write a test program to test all the methods defined in Person. Write two subclasses of Person called Student and Staff, as shown in the class diagram. The Student class contains: • An instances variable program (String), year(int) and fee(double) . • One constructor as shown. • Getter and setter for the instances variable program , year and fee. • Override the toString() method inherited, to return "A Student with [name,address] ,[program,year and fee]. The Staff class contains: • Two instance variables school (String) and pay (double). • One constructor as shown. • Getter and setter for all the instance variables. • Override the toString() method inherited, to return "A Staff [name,address],[school,pay]
Write a superclass called ؛Person (as shown in the class diagram), which
contains:
• Two instance variables name (String) and address (String).
• Two constructors: a (no-argument) constructor that initializes the name to "Ahmed"
and address to “Gaza”, and a constructor that initializes the name and address to
the given values.
• Getter and setter for all the instance variables.
• A toString() method that returns "A Person with name of xxx and address
of yyy
Write a test
Write two subclasses of Person called Student and Staff, as shown in the class diagram.
The Student class contains:
• An instances variable program (String), year(int) and fee(double) .
• One constructor as shown.
• Getter and setter for the instances variable program , year and fee.
• Override the toString() method inherited, to return "A Student with [name,address]
,[program,year and fee].
The Staff class contains:
• Two instance variables school (String) and pay (double).
• One constructor as shown.
• Getter and setter for all the instance variables.
• Override the toString() method inherited, to return "A Staff [name,address],[school,pay]
![4.2 Ex: Superclass Person and its subclasses
Write the classes as shown in the following class diagram. Mark all the overridden methods with annotation @Override.
Person
-name:String
-address:String
+Person (name:String, address:String)
+getName (): String
+getAddress ():String
+setAddress (address:String): void
+tostring():String •
"Person[name=?, address=?]"
extends
Student
Staff
-program:String
-year:int
-school:String
-pay:double
-fee:double
+Student (name:String, address:String,
program: String, year:int, fee:double)
+getProgram():String
+setProgram(program:String): void
+getYear ():int
+setYear (year:int):void
+getFee():double
+setFee(fee:double):void
+tostring():String e
+Staff(name:String, address:String,
school:String, pay:double)
+getSchool():String
+setSchool (school:String):void
+getPay():double
+setPay(pay:double):void
+toString():String e
"Staff[Person [name=?, address=?],
school=?, pay=?]"
"Student[Person[name=?, address=?],
program=?,year=?, fee=?]"](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Fa6a3976d-2b2b-4c35-a21e-723123248d78%2Ffd82f74e-3ae9-4886-8277-4aa1be0658d1%2Fd533oos_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)