The purpose of this assignment is to simulate the behavior of an aquarium that contains fish and food. An aquarium consists of n fish and m portions of food. A fish is mainly characterized by its: size: an integer between 1 and 10 inclusive. speed: an integer between 1 and 10 inclusive. hunger: an integer between 0 and 10 inclusive. tiredness: an integer between 0 and 10 inclusive. Food is characterized by its type (Plant or Meat) and its size (1, 2 or 3). Moreover, we distinguish between three types of fish: Herbivore, Omnivore and Carnivore. Based on some preconditions, the fish (regardless of its type) can do one of the following actions: grow, eat and sleep. If the preconditions are not met, the fish will not do anything. However, if the fish did one of the actions, some of the fish characteristics will change. Actions preconditions and actions consequences are listed in the table below. eat() sleep() grow() Condition Action Condition Action Condition Action Hunger > 7 & Hunger < 5 Size, hunger and Hunger decreases by food Tiredness Herbivores Tiredness > 6 tiredness increase size decreases by 3 Food type is "Plant" Tiredness < 5 by 1 Hunger > 6 Hunger decreases by food size or fish size according to & Hunger < 6 (Food type is "Meat" what was eaten Tiredness Size increases by 2 Carnivores Tiredness > 7 Or & decreases by 2 and hunger by 3 Tiredness < 5 Tiredness increases by 1/3 Fish slower and smaller by 2 points)* Hunger > 7 & of meal size Hunger decreases by food size or fish size according to Size and speed increase by 1 Tiredness decreases by 4 Hunger < 7 (Food of any type Omnivores what was eaten Tiredness > 7 & & Hunger and tiredness increase Or & Tiredness < 8 Fish of slower speed and size up till 2 points bigger)* Hunger increases by 2 Tiredness increases by 1 by 2 *Decision whether food or fish is eaten is chosen randomly. In addition to the above methods, a fish can perform a step action. In a step, every fish does only one of 3 possible things: eat, sleep or grow. Each fish has different precedence order: Herbivores: sleep, grow, eat Carnivores: eat, sleep, grow Omnivores: grow, eat, sleep Also, you must consider the following when performing a step action: 1. If the method's conditions are not met, the fish moves the next method in its order. 2. If none is met the fish does nothing. 3. If a fish is dead it does nothing in the step method. Hence, the fish dies if it was eaten, its hunger

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

Java Question

The purpose of this assignment is to simulate the behavior of an aquarium that contains fish and food. An
aquarium consists of n fish and m portions of food. A fish is mainly characterized by its:
size: an integer between 1 and 10 inclusive.
speed: an integer between 1 and 10 inclusive.
hunger: an integer between 0 and 10 inclusive.
tiredness: an integer between 0 and 10 inclusive.
Food is characterized by its type (Plant or Meat) and its size (1, 2 or 3). Moreover, we distinguish between
three types of fish: Herbivore, Omnivore and Carnivore. Based on some preconditions, the fish
(regardless of its type) can do one of the following actions: grow, eat and sleep. If the preconditions are
not met, the fish will not do anything. However, if the fish did one of the actions, some of the fish
characteristics will change. Actions preconditions and actions consequences are listed in the table below.
eat()
sleep()
grow()
Condition
Action
Condition
Action
Condition
Action
Hunger > 7
Hunger < 5
Size, hunger and
Hunger decreases by food
Tiredness
Herbivores
&
Tiredness > 6
&
tiredness increase
size
decreases by 3
Food type is "Plant"
Tiredness < 5
by 1
Hunger decreases by food
size or fish size according to
Hunger > 6
&
Hunger < 6
(Food type is "Meat"
what was eaten
Tiredness
Size increases by 2
Carnivores
Tiredness > 7
&
Or
&
decreases by 2
and hunger by 3
Tiredness < 5
Fish slower and smaller by 2
Tiredness increases by 1/3
points)*
Hunger > 7
of meal size
Hunger decreases by food
size or fish size according to
Tiredness
Size and speed
increase by 1
&
decreases by 4
Hunger < 7
(Food of any type
Hunger and
tiredness increase
Omnivores
what was eaten
Tiredness > 7
&
&
Or
&
Hunger
increases by 2
Tiredness < 8
Fish of slower speed and size
up till 2 points bigger)*
Tiredness increases by 1
by 2
Decision whether food or fish is eaten is chosen randomly.
In addition to the above methods, a fish can perform a step action. In a step, every fish does only one of 3
possible things: eat, sleep or grow. Each fish has different precedence order:
Herbivores: sleep, grow, eat
Carnivores: eat, sleep, grow
Omnivores: grow, eat, sleep
Also, you must consider the following when performing a step action:
1. If the method's conditions are not met, the fish moves to the next method in its order.
2. If none is met the fish does nothing.
If a fish is dead it does nothing in the step method. Hence, the fish dies if it was eaten, its hunger
3.
reaches 10, or its tiredness reaches 10.
Transcribed Image Text:The purpose of this assignment is to simulate the behavior of an aquarium that contains fish and food. An aquarium consists of n fish and m portions of food. A fish is mainly characterized by its: size: an integer between 1 and 10 inclusive. speed: an integer between 1 and 10 inclusive. hunger: an integer between 0 and 10 inclusive. tiredness: an integer between 0 and 10 inclusive. Food is characterized by its type (Plant or Meat) and its size (1, 2 or 3). Moreover, we distinguish between three types of fish: Herbivore, Omnivore and Carnivore. Based on some preconditions, the fish (regardless of its type) can do one of the following actions: grow, eat and sleep. If the preconditions are not met, the fish will not do anything. However, if the fish did one of the actions, some of the fish characteristics will change. Actions preconditions and actions consequences are listed in the table below. eat() sleep() grow() Condition Action Condition Action Condition Action Hunger > 7 Hunger < 5 Size, hunger and Hunger decreases by food Tiredness Herbivores & Tiredness > 6 & tiredness increase size decreases by 3 Food type is "Plant" Tiredness < 5 by 1 Hunger decreases by food size or fish size according to Hunger > 6 & Hunger < 6 (Food type is "Meat" what was eaten Tiredness Size increases by 2 Carnivores Tiredness > 7 & Or & decreases by 2 and hunger by 3 Tiredness < 5 Fish slower and smaller by 2 Tiredness increases by 1/3 points)* Hunger > 7 of meal size Hunger decreases by food size or fish size according to Tiredness Size and speed increase by 1 & decreases by 4 Hunger < 7 (Food of any type Hunger and tiredness increase Omnivores what was eaten Tiredness > 7 & & Or & Hunger increases by 2 Tiredness < 8 Fish of slower speed and size up till 2 points bigger)* Tiredness increases by 1 by 2 Decision whether food or fish is eaten is chosen randomly. In addition to the above methods, a fish can perform a step action. In a step, every fish does only one of 3 possible things: eat, sleep or grow. Each fish has different precedence order: Herbivores: sleep, grow, eat Carnivores: eat, sleep, grow Omnivores: grow, eat, sleep Also, you must consider the following when performing a step action: 1. If the method's conditions are not met, the fish moves to the next method in its order. 2. If none is met the fish does nothing. If a fish is dead it does nothing in the step method. Hence, the fish dies if it was eaten, its hunger 3. reaches 10, or its tiredness reaches 10.
An aquarium may perform a step action that makes all fish do 1 step. In addition, it increases hunger and
tiredness by 1 every 3 steps.
1) Develop the appropriate design to simulate the status of an aquarium.
2) Write a program that:
а.
Fills the aquarium by fish and food randomly
b.
Prints out the status of the aquarium (fish and food).
С.
Asks the user if he wants to step or quit?
d. If answer is quit, exit the program
е.
If answer is step, perform aquarium step and print the aquarium status
NOTE:
This is an inheritance assignment where fish is the super class and the three types of fish are
listed in the table. Note that there is an "is-a" relationship between the various types of fish
for example between "Herbivores" and the super class "fish". Make sure that your program
converges, meaning if I have for example 2 kinds of fish and 1 kind of food, the aquarium
activity after some number of steps (at most 10) should result in no food left and the two fish
dead.
Transcribed Image Text:An aquarium may perform a step action that makes all fish do 1 step. In addition, it increases hunger and tiredness by 1 every 3 steps. 1) Develop the appropriate design to simulate the status of an aquarium. 2) Write a program that: а. Fills the aquarium by fish and food randomly b. Prints out the status of the aquarium (fish and food). С. Asks the user if he wants to step or quit? d. If answer is quit, exit the program е. If answer is step, perform aquarium step and print the aquarium status NOTE: This is an inheritance assignment where fish is the super class and the three types of fish are listed in the table. Note that there is an "is-a" relationship between the various types of fish for example between "Herbivores" and the super class "fish". Make sure that your program converges, meaning if I have for example 2 kinds of fish and 1 kind of food, the aquarium activity after some number of steps (at most 10) should result in no food left and the two fish dead.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 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