0% found this document useful (0 votes)
12 views6 pages

Assignment02 (SP24 BSE 047)

The document outlines an object-oriented programming assignment that includes class diagrams and code for a hotel reservation system and a vehicle dealership system. Key classes include Customer, Vehicle, Person, and Room, each with their respective attributes and methods. The code demonstrates the implementation of these classes, showcasing inheritance and encapsulation principles.

Uploaded by

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

Assignment02 (SP24 BSE 047)

The document outlines an object-oriented programming assignment that includes class diagrams and code for a hotel reservation system and a vehicle dealership system. Key classes include Customer, Vehicle, Person, and Room, each with their respective attributes and methods. The code demonstrates the implementation of these classes, showcasing inheritance and encapsulation principles.

Uploaded by

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

Object Oriented Programming

ASSIGNMENT 02

Submitted to: - Ma’am Haseena Kainat

Submitted by: - Shaheer Qureshi

Reg-no: - SP24-BSE-047
Question No.01:
CUSTOMER

- name: String
- contactInfo: String
- paymentDetails: String
- reservations: Reservation[]

+ searchRooms()
+ makeReservation()
+ cancelReservation()
+ modifyReservation()
+ checkInOnline()

1
1

MAN
Y

HOTEL RESERVATION

- name: String
- reservationDate: localDate
- location: String
- checkInDate: localDate
- rooms: Room[]
- checkOutDate: localDate
- totalCost: double

+ addRoom() + calculateTotalCost()
+ removeRoom() + getDurationOfStay()
+ getAvailableRooms() + cancel()
+ updateRoomDetails() + modify()
+ generateInvoice()
1

MAN
1
Y

ROOM

- roomNumber: String
- type: String
- ratePerNight: double
- isAvailable: boolean

+ markAsAvailable()
+ markAsOccupied()
+ CheckAvailablity()
Question No.02: DEALER
- Customers: Customer[]

+ addCustomer(c: Customer): void


+ listCustomers(): void

CUSTOMER

- person: Person
- vehicle: Vehicle

+ getperson(): Person
+ getVehicle(): Vehicle
+ printCustomerInfo(): void

VEHICLE PERSON
- make: String - name: String
- model: String - age: int
- year: int - address: String
- price: double

+ getName(): String
+ getMake(): String
+ getAge(): int
+ getPrice(): double
+ displayDetails(): void

CAR
- numDoors: int
- numPassengers: int

+ getNumDooors(): int
+ isFamilyCar(): boolean
Code
class Vehicle {
private String make;
private String model;
private int year;
private double price;

public Vehicle(String make, String model, int year, double price) {


this.make = make;
this.model = model;
this.year = year;
this.price = price;
}

public String getMake() {


return make;
}

public double getPrice() {


return price;
}

public void displayDetails() {


System.out.println("Make: " + make + ", Model: " + model + ",
Year: " + year + ", Price: $" + price);
}
}
class Car extends Vehicle {
private int numDoors;
private int numPassengers;

public Car(String make, String model, int year, double price, int
numDoors, int numPassengers) {
super(make, model, year, price);
this.numDoors = numDoors;
this.numPassengers = numPassengers;
}

public int getNumDoors() {


return numDoors;
}

public boolean isFamilyCar() {


return numPassengers >= 4;
}
}
class Person {
private String name;
private int age;
private String address;

public Person(String name, int age, String address) {


this.name = name;
this.age = age;
this.address = address;
}

public String getName() {


return name;
}

public int getAge() {


return age;
}
}
class Customer {
private Person person;
private Vehicle vehicle;
public Customer(String name, int age, String address,
String make, String model, int year, double price) {
this.person = new Person(name, age, address);
this.vehicle = new Vehicle(make, model, year, price);
}

public Person getPerson() {


return person;
}

public Vehicle getVehicle() {


return vehicle;
}

public void printCustomerInfo() {


System.out.println("Customer Name: " + person.getName());
System.out.println("Customer Age: " + person.getAge());
vehicle.displayDetails();
}
}

You might also like