Answered step by step
Verified Expert Solution
Question
1 Approved Answer
ard/execute/content/file?cmd=view&.content_id=_2947814_1&course id=_135077_1. wwww WWW PART 1: Class Phone: A. Non-static attributes are: Phone 1. producer. 2. model. producer : String 3. production Year. model: String
ard/execute/content/file?cmd=view&.content_id=_2947814_1&course id=_135077_1. wwww WWW PART 1: Class Phone: A. Non-static attributes are: Phone 1. producer. 2. model. producer : String 3. production Year. model: String 4. hasAccessorles. production Year: Int 5. numOfAccessories: represents the number of the hasAccessories: boolean Accessories for a Phone. numOfAccessories : int 6. accessoriesArray: is an array to save the Accessories accessoriesArray: String [7] names for the phone. It has a fixed size which is 7, so the phone WithAccessoriesCount: static int maximum number of Pre-Owners are 7. Phone (String, String, Int) addAccessories (String): vold B. Static attributes are: getAccessoriesString (): string 1. phone WithAccessoriesCount: count the number of getPhoneWith AccessoriesCount(): static int Phones that have Accessories. print (): vold printAllDetails (): void C. Methods: 1. Phone (String, String, int): Set parameters to the attributes: producer, model, production Year. Set hasAccessories to false. Set numOfAccessories to Zero. 2. addAccessories (String) The parameter is a String represent the Accessory name to be added to the accessoriesArray. Check the numOfAccessories before adding to array. If the numOfAccessories is 7 print an error message to the user. Else: Check the hasAccessories, if its value is false change hasAccessories to true, and increament phoneWith AccessoriesCount by One. However, Increament the numOfAccessories by one. 3. getAccessoriesString(): Use numOfAccessories to return only the Accessories names that added to the array accessoriesArray. The value returned is a single string that separate the names by DASHs. (example: Headset - Wireless Charger) 4 getPhoneWith AccessoriesCount(): return phone With AccessoriesCount. 5. print (); print the non-static attributes: producer, model, productionYear & hasAccessories. Print it in an appropriate format 6. printAllDetails (): call print method. print the String returned from getAccessoriesString. Thia prints the Accessories names added to the array accessoriesArray . . PART 2: Class Test (that include the main method for testing): Phone Producer 1 Apple 2 Samsung 3 Huawei Model iPhone X Note 10 Nova 7 Production Year 2018 2019 2021 Accessories Headset - Wireless Charger Bluetooth Speaker A Create 3 objects of type Phone as shown in the table above. B. Add the Accessories names for each corresponding object as shown in the table above. C. Use printAllDetails to print the details for each corresponding object as shown in the table above. D. Use getPhone WithAccessoriesCount to print the number of phone with Accessories. SAMSUNG
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