Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java homework Homework 1: the Association Concept (aggregation and composition) Given the following UML class diagram: Car - name : string -id:string -seatNb : int
Java homework
Homework 1: the Association Concept (aggregation and composition) Given the following UML class diagram: Car - name : string -id:string -seatNb : int |-year: int -ncelint +Car(inn:string, in d. string, in s : int, in y:int, in size : int) +display +isFull(): bool +copyCar(in ca: Car) +addElement(in el: CarElements): bool +PriceCar(): double. CarElements -code: string -price: double 1+CarElements(inc: string, in p: double) +CarElement(in E: CarElements) +display +.....(in .........) . 1 KsuCars -nbc : int +KsuCars(in size : int) +display() +isEmpty(): bool +searchCarin ce : string): int +getCar(in nm: string): Car +Average Price(iny:int): double +.........(in .......) +remove(ins : string): bool Question: Implement all the classes with all their methods using the following descriptions. Description of the different classes: Class CarElements: The method display () displays the code and the price. (in ........) : if you need an other methods in this class you can add it. You can't add another constructor. Class Car: I name id seatNb : Number of seats year : Production year of car And other attribute(s) deduced from the UML diagram. display (): Displays all the attributes of an object Car. addElement (CarElements el): This method receives a CarElements object and adds it to the Car object. priceCar(): Returns the sum of the CarElements price in an object of the class Car. (in ........): if you need an other methods in this class you can add it. . . + ... Class KsuCars: . And other attribute(s) deduced from the UML diagram. display (): Displays all the attributes of an object KsuCars. search (String ce): This method receives a String representing the name of a Car object and returns the array index of the car object. getCar (String nm): This method receives a String representing the id of a Car object and returns the Car object if it's exist. removeCar (String s): Removes a Car according to its name. It will return a value true if the operation has been completed successfully, or false if not. AveragePrice(int y): Calculates the average price of all car in an object of class KsuCars that produced after the year y. (in .........) : if you need an other methods in this class you can add it. . The main class: In the main you should be able to create a KsuCars with at least 3 cars. Each car has at least 4 car element. A display should be called to see all the entered data . Class KsuCars: nbc : number of Car currently in an object of the class KsuCar. And other attribute(s) deduced from the UML diagram. . display (): Displays all the attributes of an object KsuCars. search (String ce): This method receives a String representing the name of a Car object and returns the array index of the car object. getCar (String nm): This method receives a String representing the id of a Car object and returns the Car object if it's exist. removeCar (String s): Removes a Car according to its name. It will return a value true if the operation has been completed successfully, or false if not. AveragePrice(int y): Calculates the average price of all car in an object of class KsuCars that produced after the year y. (in ........) : if you need an other methods in this class you can add it. +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