JAVA assignment: Complete the design and coding for a BobsLife class. Bob's Life simulates a simple virtual world. In this world there is a person called Bob that is at one of three locations -...


JAVA assignment:
Complete the design and coding for a BobsLife class.


Bob's Life simulates a simple virtual world. In this world there is a person called Bob that is at one of three
locations - "home", "work", or "gym" (default "home"). Bob has three whole number characteristics:

his hunger (default 0), his fitness (default 4), and his dollars (default 5).

Every time Bob moves, his time counter is incremented. The move rules are:


If Bob is moved home, then his hunger is decreased by 3 (but hunger cannot go negative), because he eats a meal.

Furthermore, his dollars are decreased by 1 because food costs money.
If Bob is moved to work, then his hunger is increased by 2, because working makes him hungry.
Furthermore, his dollars are increased by 3, he earns money at his job. Also, he has a desk job,
so his fitness decreases by 1.
If Bob is moved to the gym, then his hunger is increased by 3 because a workout makes him hungry.
His dollars are decrease by 2 since the gym costs money. On the positive side his fitness increases by 2.
Bob's intial status is "alive and well". But the virtual world is quite harsh. If Bob’s hunger goes above 6, then the

poor guy starves to death (status "deceased"). If his dollars drop below zero, then he is broke and is thrown into jail

for a life time sentence (status "in jail"). If his fitness drops to 0 or lower, then he dies of a heart attack

(status "deceased"). It may be easiest to use instance attribute booleans to keep track of whether Bob is dead or in

jail. If either, or both, of these things happen, then it should no longer be possible to move Bob to another location

and his characteristics no longer change.


Create a BobsLife class with necessary instance attributes and class constants, and the following methods:


Non-Default Constructor - BobsLife (String initialLocation, int initialHunger, int initialDollars, int initialFitness) -

All arguments should be checked for validity and default values assigned if necessary.
No Accessors - non-default constructor should perform all argument checking.
Mutator - move(String newLocation) - If Bob is not "alive and well", then output Bob's toString(). If Bob is
"alive and well":
verify the newLocation is valid (default if necessary) increment the time counter move Bob to that location
update his characteristics based on the above move rules.
update his status toString method that returns a String as shown.
Time:0 Location:home Hunger:0 Dollars:5 Fitness:4 (alive and well)
To break down required functionality into smaller pieces, you should consider other private methods that the above
public methods call.
Jan 18, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here