You are required to build a mini FunTime application for the kids to playwith their electronic toys in a virtual world. Follow the given steps Build a class Toy having the following data members Name(String) Color (String) Type (String) Price (float) batteryHealth (int) Provide constructor with arguments for name, color, type, and price. Initialize batteryHealth to 5 (which means full). Provide getter for each of these but no setters. Provide a function charge(String time). This function would increase the batteryHealth of the toy according to following rules Time Increase in battery health 15 mins 20% charging (Increase health by 1) 30 mins 40% 45 mins 60% 1 hour 80% 1 hour 15 mins 100% If the toy is already fully charged, then no more charging should be done and appropriate message to be displayed. The charge function returns the new health of the battery of toy object. Provide another function play() that reduces the batteryHealth of the toyby 1 but it cannot go below 0. Provide a function bool isDead() this function returns true if the batteryHealth is 0 and false otherwise. Provide a function bool isCritical(). This function should return true if the battery health is below 20%. Add another function replaceBattery(). This function should replace the batteryHealth back to 5, however, user should be able to call this function only 3 times for any specific toy. Provide the toString method which returns a formatted string showing the details of this toy. Build a class Person with the following data members/instance variables Name b. Toy [] toys; This class represents a person who owns one or more toys. The toys array is an aggregation of the Toy object in Person Class. You will provide a constructor taking the name of the person as argument and the number of toys he/she has. Initialize the name and instantiate the array to the size provided in the constructor. Provide a method addToy(Toy p) which adds this toy object p to the array. You might want to add more instance variables to this class to help you in manipulating the array Provide a method startPlay(String toyName). This method searches the toy with the given name in the array and then call its play method. Provide a method getToy(String name) which searches for the toy with given name in the array and then returns it. If it is not found, then null should be returned Write main method to test each part of your code.
(Already solved on bartleby)
https://www.bartleby.com/questions-and-answers/you-are-required-to-build-a-mini-funtime-application-for-the-kids-to-playwith-their-electronic-toys-/e552db61-3d87-40b1-911d-a0b6f9a66394
Please provide solution
You are required to build a mini FunTime application for the kids to playwith their electronic toys in a virtual world. Follow the given steps
Build a class Toy having the following data members
Name(String)
Color (String)
Type (String)
Price (float)
batteryHealth (int)
Provide constructor with arguments for name, color, type, and price. Initialize batteryHealth to 5 (which means full).
Provide getter for each of these but no setters.
Provide a function charge(String time). This function would increase the batteryHealth of the toy according to following rules
Time
Increase in battery health
15 mins
20% charging (Increase health by 1)
30 mins
40%
45 mins
60%
1 hour
80%
1 hour 15 mins
100%
If the toy is already fully charged, then no more charging should be done and appropriate message to be displayed. The charge function returns the new health of the battery of toy object.
Provide another function play() that reduces the batteryHealth of the toyby 1 but it cannot go below 0.
Provide a function bool isDead() this function returns true if the batteryHealth is 0 and false otherwise.
Provide a function bool isCritical(). This function should return true if the battery health is below 20%.
Add another function replaceBattery(). This function should replace the batteryHealth back to 5, however, user should be able to call this function only 3 times for any specific toy.
Provide the toString method which returns a formatted string showing the details of this toy.
Build a class Person with the following data members/instance variables
Name
b. Toy [] toys;
This class represents a person who owns one or more toys. The toys array is an aggregation of the Toy object in Person Class.
You will provide a constructor taking the name of the person as argument and the number of toys he/she has. Initialize the name and instantiate the array to the size provided in the constructor.
Provide a method addToy(Toy p) which adds this toy object p to the array. You might want to add more instance variables to this class to help you in manipulating the array
Provide a method startPlay(String toyName). This method searches the toy with the given name in the array and then call its play method.
Provide a method getToy(String name) which searches for the toy with given name in the array and then returns it. If it is not found, then null should be returned
Write main method to test each part of your code.
Step by step
Solved in 3 steps with 1 images