Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Lab 04

Composition

1. Create a class Course. The course has course code, course name, and number of
credit hours. The instance variables are initialized through a constructor. Create the
setter and getter methods for all the variables. Write a toString method that displays
the course details in the following format:

CS101 Introduction to Computing Credit Hours: 4

2. Create a class Faculty. A faculty member has a name, monthly salary, one or more
courses, and the number of credit hours. A faculty member is allocated more than
12 credit hours, he or she is paid PKR2800 extra per credit hour per month. Create
a constructor to initialize the variables, the setter and getter and other appropriate
methods required. Use composition to include the course details in the Faculty class.
Write a toString method to display the faculty and course details in the following
format.

Faculty Name: Majid Khan


Course: CS101 Introduction to Computing Credit Hours: 4


Number of Credit Hours: 15
Monthly Salary: PKR65000
Total Income: 73400

3. Write a client class that initializes and prints the objects of the two classes.

You might also like