Solve the following problem using java programming
language.
1. Suppose your name is Sam Roxton. You are 35 years old and are a lawyer. You are a VIP member of a club known as the Horsemen. This club has two kinds of members: VIP members and Regular members. Your friend's name is Poppy Wyatt. Poppy is an artist who is 36 years old. She is a regular member of this club. Create a Member class, a VIPmember class and a Regular Member class. VIPmember and Regular Member classes are child classes of the Member class. The constructor of the Member class prints out "I am a member". Member class has the following attributes: Name, Age, Profession. VIPmember's constructor prints out "I am a VIP member" and initializes the attributes of Member class. However, before doing that, from the constructor of the VIPmember class, call the constructor of the Member class (.e. superclass). So calling the constructor of VIPmember should work in the following way: 1/print out "I am a member" by calling the constructor of the parent class Member //Simply print out "I am a VIP member". //Initialize name, age and profession attributes. Regular Member's constructor prints out "I am a Regular member" and initializes the attributes of Member class. However, before doing that, from the constructor of the RegularMember class, call the constructor of the Member class (i.e. superclass). So calling he constructor of RegularMember should work in the following way:
//print out "I am a member" by calling the constructor of the parent class Member 1/Simply print out "I am a Regular member". //Initialize name, age and profession attributes. From the main function, create an object of VIPmember and send the parameters: Sam Roxton, 35 and lawyer in the constructor. Also, create an object of Regular Member and send the parameters: Poppy Wyatt, 36, artist in the constructor. 2. Create a class named "Manager". This class has two private attributes: Salary, Address. You want to access those private members from the Main class. You have to create an object of the Manager class then use the setter and getter methods to access those attributes.
Solve the following problem using java programming language.
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am