Question
Given the following UML diagram: Part 1: Implement the following classes: Check the notes below before you start: AccidentReport - date: Date - involvement: Vehicle[]
Given the following UML diagram:
Part 1: Implement the following classes: Check the notes below before you start:
AccidentReport |
- date: Date - involvement: Vehicle[] - nbOfVehicle: int |
+ AccidentReport () + getDate ():Date + addNewVehicle(v: Vehicle): void + cruiserMotoInvolved():boolean + countAutomaticCars():int + displayOwners(): void |
Vehicle |
- owner:String - matriculation: String - model: String |
+ Vehicle (----All Parameters----) + setters/getters + toString(): String |
Motorcycle |
- torque: double - type: String // standard, cruiser or sport |
+ Motorcycle (----All Parameters----) + setter/getter + toString(): String |
Car |
- horsePower: int - automatic: boolean |
+ Car (----All Parameters----) + setter/getter + toString(): String |
Notes:
-
The Vehicle class: (10pts)
-
The ToString method should return a String similar to :
-
Model: BMW, Owner: Ali Moussa, Matriculation: S1234
-
The car class: (10pts)
-
The ToString method should return a String similar to :
-
Car : BMW, Owner: Ali Moussa, Matriculation: S1234, Automatic, 255 hp
OR
Car: BMW, Owner: Ali Moussa, Matriculation: S1234, Manual, 255 hp
-
The motorcycle class: (10pts)
-
The toString method should return a String similar to:
-
Sport Motorcycle: BMW, Owner: Ali Moussa, Matriculation: S1234, 50 N
-
The AccidentReport class: : (50pts)
-
The involvement array can have at most 10 elements.
-
The date data field should include the current date (exact date of object creation)
-
The nbOfVehicle should register the real number of involved Vehicle (how many elements has been added to the array).
-
The AccidentReport () constructor will create an object with the current date, involvement array of size 10 and nbOfVehicle equal to zero.
-
addNewVehicle(v: Vehicle) adds new Vehicle to the array (if the array is not full)
-
cruiserMotoInvolved() returns true if a Motorcycle of type Cruiser has been involved in the accident. And false otherwise.(by searching the involvement array)
-
countAutomaticCars() returns the number of automatic cars that has been involved in this accident. .(by searching the involvement array)
-
displayOwners(): Display the names of owners of all involved Vehicles.
-
Part 2: Implement a driver class (main class) as follows: (20pts)
-
Create an AccidentReport object.
-
Add to the report object 2 Cars objects and 1 Motorcycle of your choice.
-
Add to the report object one automatic Car of Model BMW horsepower equal to 600 owned by oussama atwi and has matriculation nb S123123.
-
Display the number of automatic cars involved in this report.
-
Display if any cruiser motorcycle has been involved.
-
Display all Owners names.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started