0% found this document useful (0 votes)
344 views15 pages

CSC186 Report

The document outlines the design of a car rental system including class definitions for cars, sedans, and motors with inheritance and polymorphism. It includes UML diagrams showing the class relationships and rental process use cases. The main method demonstrates adding sample vehicles to the system and allowing a customer to select a car and display the rental price calculated based on the car and rental duration.

Uploaded by

saiful syahmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
344 views15 pages

CSC186 Report

The document outlines the design of a car rental system including class definitions for cars, sedans, and motors with inheritance and polymorphism. It includes UML diagrams showing the class relationships and rental process use cases. The main method demonstrates adding sample vehicles to the system and allowing a customer to select a car and display the rental price calculated based on the car and rental duration.

Uploaded by

saiful syahmi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

CSC 186 : OBJECT ORIENTED PROGRAMMING

CS110 DIPLOMA SCIENCE COMPUTER

FAKULITI KOLEJ PENGAJIAN


PENGKOMPUTERAN ,
INFORMATIK DAN MEDIA
KCDCS1102B

PREPARED

BY :

NAMA NO PELAJAR
1.MUHAMAD NOR ADAM BIN 2022841328
SHAMSUL ANUAR
2.MUHAMMAD KHABIR BIN 2022894962
JAMALUDIN
3.MAHATHIR BIN MOHD TAHIR 2022603738
4.SAIFUL SYAHMI BIN 2022628884
SAIFULBAZLI

PREPARED FOR :

DR KHAIRUL ADILAH
BINTI AHMAD

1
TABLE OF CONTENT

1. ORGANIZATIONAL STRUCTUR… .................................................................................. 3


2. INTRODUCTION… .............................................................................................................. 4
3. OBJECTIVES........................................................................................................................5
4. SCOPE ................................................................................................................................... 6
5. UML DIAGRAM… ................................................................................................................. 7
5.1 USE CASE DIAGRAM .................................................................................................. 8
6. INPUT OUTPUT FILE ............................................................................................................9
7. CLASS DEFINITION OF HERITANCE,POLYMIRPHISM AND RELATED CLASS…10-11
8. CLASS APPLICATION .......................................................................................................... 12-13
9. OUTPUT FILE .......................................................................................................................... 14
10. REFERENCES .......................................................................................................... 15

2
1.0 ORGANIZATIONAL STRUCTUR
Chart Organization

Owner
MAHATHIR BIN MOHD TAHIR

Sales Personal

SAIFUL SYAHMI BIN SAIFUL BAZLI

Accountant Secretary
MUHAMMAD KHABIR BIN 3
MUHAMAD NOR ADAM BIN
2.0 INTRODUCTION

Welcome to our premier car rental service! We are thrilled to offer you a
convenient and reliable solution for all your transportation needs. Whether you're a
frequent traveler, a tourist exploring new destinations, or simply in need of a
temporary vehicle, our car rental service is here to provide you with a seamless and
enjoyable experience.

At our car rental service, we understand the importance of freedom, flexibility,


and convenience when it comes to getting around. We strive to make your journey
as smooth as possible, offering a wide range of well-maintained vehicles that cater to
different preferences and requirements. From compact cars for city commuting to
spacious SUVs for family adventures, we have the perfect vehicle to suit your needs.

Customer satisfaction is at the heart of our service. Our dedicated team of


professionals is committed to providing exceptional customer service, assisting you
throughout the rental process and ensuring that your experience with us exceeds
your expectations. We take pride in our prompt and friendly service, ensuring that
you feel valued and well taken care of from the moment you make a reservation until
you return the vehicle.

Safety is of utmost importance to us. We meticulously maintain our fleet to


ensure that every vehicle is in optimal condition and meets the highest safety
standards. Additionally, we provide comprehensive insurance coverage, giving you
peace of mind and protection during your rental period.

4
3.0 OBJECTIVES

1. Increasing operational efficiency.

2. To ensure a high level of customer satisfaction.

3. Ensuring the safety of customers and vehicles.

5
4.0 SCOPE

Class diagram
1. There are 4 classes; carRental, Sedan, Motor, customer.
2. Customer and carRental has a many-to-many relationship with no aggregation link. It
is a part of relationship where carRental is the whole and Customer is the part-of
objects. This implies a relationship which part of object Customer can still exist
independently of the whole object.
3. Sedan and Motor are type of carRental. This implies inheritance relationship where
carRental has general attributes; rental price, make,year and model. Sedan has
unique attribute which is car type ,colour and number of seats.

Use Case Diagram

1. Two actor which is customer and employees.


2. Processes;
a.Customer register first.
b. .Customer can choose car.
c. Customer can choose the model.
d.Customer can input year.
e. Employees and customer both can see the car status whether its is available or not.
f.Customer get total price.
g.Customer make a payment.
h.Customer can rent a car.
i.Employees calculate the price.
j.Employees can see customer details.

6
5.0 UML DIAGRAM

UML Class Diagram

7
UML Use Case Diagram

8
6.0 INPUT FILE

9
7.0 CLASS DEFINITION OF INHERITANCE, POLYMORPHISM AND RELATED CLASSES

SUPERCLASS

// Car superclass
public class Car {
private String brand;
private String model;
private int year;
private double rentalPrice;

public Car(String brand, String model, int year, double rentalPrice) {


this.brand = brand;
this.model = model;
this.year = year;
this.rentalPrice = rentalPrice;
}

public String getBrand() {


return brand;
}
public String getModel() {
return model;
}
public int getYear() {
return year;
}
public double getRentalPrice() {
return rentalPrice;
}

@Override
public String toString() {
return brand + " " + model + " " + year + ", Rental Price: RM" + rentalPrice;
}

10
SUBCLASS

// Sedan subclass

public class Sedan extends Car {


private int numberOfSeats;

public Sedan(String brand, String model, int year, double rentalPrice, int numberOfSeats)
{

super(brand, model, year, rentalPrice);


this.numberOfSeats = numberOfSeats;
}
public int getNumberOfSeats() {
return numberOfSeats;
}

@Override
public String toString() {
return super.toString() + ", Number of Seats: " + numberOfSeats;
}
}

// Motor subclass
public class Motor extends Car {
private double engineDisplacement;

public Motor(String brand, String model, int year, double rentalPrice, double
engineDisplacement) {
super(brand, model, year, rentalPrice);
this.engineDisplacement = engineDisplacement;
}
public double getEngineDisplacement() {
return engineDisplacement;
}
@Override
public String toString() {
return super.toString() + ", Engine Displacement: " + engineDisplacement + "cc";
}
}

11
8.0 CLASS APPLICATION

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

// Car Rental System


public class CarRentalSystem {
private List<Car> availableCars;

public CarRentalSystem() {
availableCars = new ArrayList<>();
}

public void addCar(Car car) {


availableCars.add(car);
}

public void displayAvailableCars() {


System.out.println("Available Cars for Rental:");
for (Car car : availableCars) {
System.out.println(car);
}
}

public double calculateRentalPrice(Car car, int numberOfDays) {


return car.getRentalPrice() * numberOfDays;
}

public static void main(String[] args) {


CarRentalSystem rentalSystem = new CarRentalSystem();

// Adding sample cars


Sedan sedan1 = new Sedan("0. Toyota", "Camry", 2020, 50, 5);
rentalSystem.addCar(sedan1);

Motor motor1 = new Motor("1. Harley-Davidson", "Sportster", 2019, 80, 1200.0);


rentalSystem.addCar(motor1);

Sedan sedan2 = new Sedan ("2. Honda", "BRV", 2020, 60, 7);
rentalSystem.addCar (sedan2);

Sedan sedan3 = new Sedan ("3. Honda", "Civic FD", 2010, 90, 5);
rentalSystem.addCar (sedan3);

Motor motor2 = new Motor("4. Yamaha", "LC", 2019, 20, 135.0);


rentalSystem.addCar(motor2);

Motor motor3 = new Motor("5. Yamaha", "Lagenda", 2018, 15, 125.0);


rentalSystem.addCar(motor3);

12
// Customer input
Scanner scanner = new Scanner(System.in);

System.out.print("Enter customer name: ");


String customerName = scanner.nextLine();

System.out.print("Enter customer phone number : ");


String customerPhone = scanner.nextLine();

System.out.print("Enter rental duration in days: ");


int rentalDuration = scanner.nextInt();

// Calculate rental price


System.out.println("\nCustomer: " + customerName);
System.out.println("Rental Duration: " + rentalDuration + " days\n");

rentalSystem.displayAvailableCars();

System.out.print("\nEnter the number of the car you want to rent: ");


int carIndex = scanner.nextInt();
System.out.println("\nCalculating rental price...");

if (carIndex >= 1 && carIndex <= rentalSystem.availableCars.size()) {


Car selectedCar = rentalSystem.availableCars.get(carIndex);

double rentalPrice = rentalSystem.calculateRentalPrice(selectedCar, rentalDuration);

System.out.println("\n===============================================");
System.out.println("\t\t CAR RENTAL RECEIPT");
System.out.println("===============================================");
System.out.println("\nRenting Details:");
System.out.println("\nName : " + customerName);
System.out.println("Phone Number " + customerPhone);
System.out.println("Car: " + selectedCar);
System.out.println("Rental Price: RM" + rentalPrice);
} else {
System.out.println("Invalid car selection.");
}
}
}

13
9.0 OUTPUT FILE OR/AND SAMPLE INTERFACES

14
10.0 REFERENCE SOLP,
1. DR Khairul Adilah Binti Ahmad

15

You might also like