CS506 Assignment 1 Solution Fall 2017

Question:     (20 Marks)

You are required to write a program in java that will contain four classes.

1. The name of super class should be same as your own VU ID (like BC00000000) and it will have three data members i.e. stdId, stdName and studyProgram. BC00000000 class must have following methods:

  • Parameterized constructor that will initialize all the data members with the given values.
  • Getters and Setters for each data member that will get and set the values of data members of class.
  • A display function that will display all the data members of the class.

2. The name of second class should be HomeBasedStudent and it will be inherited from super class (BC00000000). It will have two data members i.e. homeAddress and phoneNumber. HomeBasedStudent class must have following methods:

  • Parameterized constructor that will initialize all the data members with the given values.
  • Getters and Setters for each data member that will get and set the values of data members of class.
  • A display function that will override the display() method of BC00000000 class and must call display() method of superclass within overridden method before printing data members of HomeBasedStudent class.

3. The name of third class should be CampusBasedStudent and it will also be inherited from super class (BC00000000). It will have three data members i.e.campusName, campusAddress and phoneNumber. CampusBasedStudent class must have following methods:

  • Parameterized constructor that will initialize all the data members with the given values.
  • Getters and Setters for each data member that will get and set the values of data members of class.
  • A display function that will override display() method of BC00000000 class and must call display() method of superclass within overridden method before printing data members of CampusBasedStudent class.

4. The name of fourth class should be Driver which will contain the main method. In main method, if you are a home based student then create an instance of class HomeBasedStudent and initialize all the data members with your own VU ID, name, study program, home address and phone number.

And, if you are campus based student then create an instance of class CampusBasedStudent and initialize all the data members with your own VU ID, name, study program, campus name, campus address and phone number.

After that, call the display method using the object of relevant class. Your output should be displayed like.

In case of home based student:

VU ID : BC0000000

Name: Ali

Study Program: BS CS

Home Address: Model Town Lahore

Phone Number: 1234567

In case of Campus based student:

VU ID : BC0000000

Name: Ali

Study Program: BS CS

Campus Name:           VLHR01

Campus Address: Faisal Town Lahore

Phone Number: 1234567

Download The Solution Here CS506Assignment01Solution

DOWNLOAD SOLUTION HERE
loading...