Please can I have it in language Java? This is a project and all questions are related.
Implement the below classes except the class Tshirt, which you can assume its code exists when you need to call its methods.
ShoppingCart:
- items: Item[]
- nbAddedItems: int
- ShoppingCart(maxNbItems: int)
- getItems(): Item[]
- addItem(i: Item): void
- getNbAddedItems(): int
- buyItem(id: int): double
- getNumberOfShoes(): int
- displayTshirts(color: String): void
- toString(): String
Item:
- id: int
- price: double
- brand: String
- Item(id: int, price: double, brand: String)
- Getters/Setters
- toString(): String
Shoe:
- size: int
- Shoe(id: int, price: double, brand: String, size: int)
- Getters/Setters
- toString(): String
Tshirt:
- color: String
- Tshirt(id: int, price: double, brand: String, color: String)
- Getters/Setters
- equals(o: Object): boolean
- toString(): String
A. Item Class:
1. Assuming that we have an Item whose id is 123, price is 98, and brand is Adidas, the toString() method should return a String with the following format: "ID:123, Price:98.0, Brand:Adidas"
B. Shoe Class:
1. Assuming that we have a Shoe whose id is 123, price is 98, brand is Adidas, and size is 40, the toString() method should return a String with the following format: "Shoe: ID:123, Price:98.0, Brand:Adidas, Size:40"
C. Tshirt Class: (Do not implement this class)
1. The equals() method returns true if both Tshirt Objects have the same color and price.
2. Assuming that we have a Tshirt whose id is 123, price is 98, brand is Adidas, and color is Black, the toString() method should return a String with the following format: "T-shirt: ID:123, Price:98.0, Brand:Adidas, Color:Black"
D. ShoppingCart Class:
1. The data field nbAddedItems keeps track of the number of items added to the items array.
2. The constructor accepts an int parameter maxNbItems, which indicates the maximum number of Item Objects that could be added to the items array.
3. The method addItem adds an item Object to the items array.
4. The method buyItem searches for the Item Object with the specified id in the items array. If the Item is found in the array, return its price. Otherwise, return -1.
5. The method getNumberOfShoes returns the number of Shoe Objects found in the items array.
6. The method displayTshirts displays information about all the Tshirt Objects in the items array with the specified color.
7. The toString method returns a String containing information about all the Item Objects in the items Array.