Labmidpaper
Labmidpaper
programming
Lab Mid
(oop)
Submitted by :
Muhammad Zohaib (sp23-bcs-071)
Submitted to :
Mam Hasina kainat
Question_No:1:
You work for a car rental company, and your task is to implement a system that models different
cars in the fleet. Each car has an engine, tires, and a fuel tank, all of which contribute to the car's
overall functionality. You need to create classes to represent these components and show how
the car uses them to display relevant information (e.g., horsepower, tire type, fuel level, etc.).
Answer:
}
public class FuelTank { private
double fuelLevel;
Question_No:02:
Suppose you have to develop a human resources management system for a company. The
company has both full-time and part-time employees, and you need to design a class hierarchy
that represents these employees. Each employee has a name, position, and salary. Full-time
employees have a fixed salary, while part-time employees are paid based on their hourly rate
and the number of hours they work. You also need to calculate their salary and display their
details in the system for both full –time employees and part-time.
Answer:
}
class FullTimeEmployee extends Employee {
private double salary;
@Override
public double calculateSalary() {
return salary;
}
}
Output:
Question_No:03:
Design a system for managing the operations of a Library, which allows users to borrow and
return books, search for books, and manage their memberships. The system should support
multiple libraries, each containing various categories of books (e.g., Fiction, NonFiction, Science,
History). Each book has attributes like title, author, ISBN, genre, and availability status.
System Features:
· Library Management: Libraries can manage their collection of books, update book details, track
the borrowing and return process, and mark books as available or unavailable.
· User Membership: Users (members) must register in the system, providing their personal
details, membership ID, and contact information. They can search for books based on title,
author, genre, or availability, and borrow them.
· Book Borrowing: Once a user finds a suitable book, they can borrow it for a specified duration.
The borrowing process includes the due date and any late fees if the book is not returned on
time. Users can also extend the borrowing period.
The system should ensure that both library staff and users can interact with the system
intuitively, allowing library staff to manage the collection and track borrowing activities
effectively.
2. Define attributes for each class based on the system’s requirements (e.g., books, users, library
staff).
3. Define methods for each class, such as searching for books, borrowing, returning, and
generating receipts.
4. Demonstrate encapsulation where necessary, particularly for sensitive data like user
information and payment details for late fees.
Answer: import
java.util.*;
library.addBook(book1);
library.addBook(book2); library.addBook(book3);
Output: