Professional Documents
Culture Documents
Class_Assignment2-FA23 (1)
Class_Assignment2-FA23 (1)
CLO-2: Apply the concepts of object-oriented programming principles (abstraction, inheritance, and
polymorphism.) along with interfaces and exception handling to solve a real-world problem.
Instructions
Total Marks: 15
Submit assignment in printed form and upload the same on MS Teams along with source code.
Assignment document must contain a title page showing Assignment-2, your name and registration number.
For JAVA Programs, you must follow proper JAVA naming convention for identifiers and properly document
your source code.
Plagiarism: Plagiarism is not allowed. If found plagiarized, zero marks will be awarded in the assignment.
COMSATS University Islamabad
Department of Computer Science
Object Oriented Programming (CSC241) – BSDS3A
Class Assignment – 2
Question – 1
Design a class named Person and its two subclasses named Student and Employee. Make Faculty and Staff
subclasses of Employee. A person has a name, address, phone number, and email address. A student has class
status (freshman, sophomore, junior, or senior). Define the status as a constant. An employee has an office,
salary, and date hired. Use the MyDate class defined in Programming Exercise 10.14(Liang) to create an object
for date hired. A faculty member has office hours and a rank. A staff member has a title. Override the toString
method in each class to display the class name and the person’s name.
Draw the UML class diagram for the classes and implement it.
Question – 2
Package-delivery services offer several different shipping options, each with specific costs associated.
Base class Package should include data members representing the name and address for both the sender
and the recipient of the package, in addition to data members that store the weight (in ounces) and cost per
ounce to ship the package.
The address class has data members, houseNo, StreetNo, City, Country and zipCode.
Package's constructor should initialize these data members. Ensure that the weight and cost per ounce
contain positive values.
Package should provide a public member function calculateCost() that returns a double indicating the cost
associated with shipping the package.
Package's calculateCost() function should determine the cost by multiplying the weight by the cost per
ounce.
Derived class TwoDayPackage should inherit the functionality of base class Package, but also include a data
member that represents a shipping fee that the shipping company charges for two-day-delivery service.
TwoDayPackage's constructor should receive a value to initialize this data member. TwoDayPackage should
redefine member function calculateCost() so that it computes the shipping cost by adding the shipping fee
to the cost calculated by base class Package's calculateCost() function.
Class OvernightPackage should inherit from class Package and contain an additional data member
representing an additionalfee charged for overnight-delivery service.
OvernightPackage should redefine member function calculateCost() so that it computes the shipping cost by
adding the additionalfee to the cost calculated by base class Package's calculateCost() function.
Draw UML class diagram for the classes and as well as its implementation.
COMSATS University Islamabad
Department of Computer Science
Object Oriented Programming (CSC241) – BSDS3A
Class Assignment – 2
Question – 3
Create class diagram and perform implementation for a shop management system. The system will have
following features:
• You need to identify the class structure for the above system.
• Analyze the data in each class.
• Add suitable methods.
• Analyze relationships between classes.
• You may add supporter classes for the system.