CSC186 Report
CSC186 Report
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
2
1.0 ORGANIZATIONAL STRUCTUR
Chart Organization
Owner
MAHATHIR BIN MOHD TAHIR
Sales Personal
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.
4
3.0 OBJECTIVES
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.
6
5.0 UML 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;
@Override
public String toString() {
return brand + " " + model + " " + year + ", Rental Price: RM" + rentalPrice;
}
10
SUBCLASS
// Sedan subclass
public Sedan(String brand, String model, int year, double rentalPrice, int 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;
public CarRentalSystem() {
availableCars = new ArrayList<>();
}
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);
12
// Customer input
Scanner scanner = new Scanner(System.in);
rentalSystem.displayAvailableCars();
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