(already solved on bartleby) 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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

(already solved on bartleby)

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.

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY