Question: Problem 6. (25 points) Goal: Practice how to create user-defined classes in Java. Design a Java class for Person with the following behaviours: talk, in

 Problem 6. (25 points) Goal: Practice how to create user-defined classes

Problem 6. (25 points) Goal: Practice how to create user-defined classes in Java. Design a Java class for Person with the following behaviours: talk, in which a person can talk a sentence, if s/he is at least two-year old. eat, in which a person can eat something i s/he is hungry. If the person eats something, then s/he becomes full (not hungry). needFood, in which the person's status will become hungry if s/he is currently full. walk, in which a person will walk a specific distance. If a person walks more than four kilometers, then s/he becomes tired and is not able to walk anymore. sleep, in which a person will slccp if s/he is awake. If a person slccps, then s/he is no tired anymore, her/him walking distance will resct, and s/hc can walk again. Note that if a person is slccping, s/hc can't walk. awake, in which the person is awaken if s/he is currently sleeping. grow, in which the person's age will increase by one year. If a person reaches to 55, then his ability to walk will decrease by hall every five years. You need to indicato all the instance variables (propertics) a givc person should have to be able to handle the above list of behaviors and store the current states of a given person. For instance, every person has name, age, current distance of walking, sleeping status, walking distance capability, etc. After designing the Person class, implement it as a Java class. Then write a tester Java program to test that class by creating some Person instance objects and do some actions for each of them. To make sure that your tester program tests all the functionalities of a given person, you have to call every method of the class at least once. Assume that every person can have onc friend, which is another person. Therefore, two other behaviors for a person could be getFriend and changeFriend. Modify thc Person class that you have designed to be able to handle these two behaviours as well. Note that you need to have another instance variable as well. Java file names: Person.java and TestPerson.java

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!