Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java:coding using the information below from the picture: This assignment is about objects, instance variables, methods and encapsulation. You will create two classes to simulate

java:coding using the information below from the picture:
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
This assignment is about objects, instance variables, methods and encapsulation. You will create two classes to simulate the world of "ParrotCraft" - a simple game world loosely based on MineCraft Parrot objects. In graphical applications, programmers often separate the model from the view. The model keeps track of the internal state of the program, and the view is in the middle between the user and the model. It talks to the user through a user interface, and it talks to the model by calling its methods and interpreting the return values from those methods. The model never talks directly to the user. This is not a graphical application. In this assignment, the Parrot class is the model and the ParrotCraft class implements a "view" that consists of a text-based conversation with the user. If you implement the model well, it should be easy to re-use it later in a graphical view. tep 1: Design and UML our first step should be to create a UML class diagram to represent a Parrot. You should create his diagram using UML software like UMLet or draw.io (links on Canvas). Don't use a plain word processor like Microsoft Word. If you want to use a different piece of software, you must check with the instructor first. UML Diagrams that are generated automatically from code are also not allowed. - A Parrot has a name, an integer number of hearts that represent its health, and the amount of cracker crumbs in its stomach, in grams. A Parrot can be tamed or untamed, it can be dead or alive, and it can be flying or sitting. - You can feed a Parrot some cracker crumbs. Its health goes up by 1 (maximum 3 ) every time you feed it. The amount of cracker crumbs in its stomach rises also. - When you feed a Parrot, there is a chance that the parrot will become tamed. The percentage chance of taming is 20 crumbs, where crumbs is the amount of cracker crumbs in kilograms you just fed it. - A Parrot can also eat too much and make itself sick. When a Parrot has more than 2.5kg of cracker crumbs in it's stomach its health (hearts) will go do down by 2 . If the health (hearts) becomes 0 , the Parrot becomes dead. - You can command a tamed Parrot to stay or fly. An untamed Parrot is always flying: - You can give a tamed Parrot a different tamed Parrot to play with. But the Parrots will rediscover the joy of their own species, making both of them untamed. - You can hit a Parrot and make its health go down by 1 (minimum 0). Hitting a Parrot always makes it untamed and sometimes makes it dead (if it has 0 health). 1 - Dead Parrots can't be fed, can't be told to stay or move, and can't play with other Parrots. 2 - When a Parrot is "born" (i.e., an instance created) it alive and untamed and flying with 3 health. By default, its name is "Jullus" and it has 0.1kg of cracker crumbs in its stomach, but you can change its name and the amount of cracker crumbs in its stomach after you create the Parrot. (By using sefters) - There should be a tostring method that returns a full report on a Parrot. It is completely up to you what the return value of tostring looks like, but don't just use the default from Intellij. IMPORTANT BASIC RULE HI: The Parrot class is the model. The model should never talk to the user. The model should request no input and produce no output. All input should be passed into the Parrot objects using the method parameters. All information to be outputted should be returned by the method. Step 2: Implement the Parrot and ParrotCraft Classes Once the class diagram is finished, implement your Parrot class in Java code. Then write a main method in a different class to simulate a user interacting with the Parrots in the world of ParrotCraft. This method should create three Parrot objects and allow a user to interact with each one using a menu interface. It's up to you how you structure the dialog, but one possibility is shown in the example dialog below. 1. Tamed DEAD Parrot Julius: 2.1kg crumbs, 0 hearts 2. Untamed Parrot Nancy: 0.6kg crumbs, 1 heart, flying 3. Tamed Parrot Johnette: 1.0kg crumbs, 3 hearts, sitting 1. Feed 3. Play 4. Hit 5. Quit Choice: 4 Which parrot? 3 ouch! 1. Tamed DEAD Parrot Julius: 2.1kg crumbs, 0 hearts 2. Untamed Parrot Nancy: 0.6kg crumbs, 1 heart, flying 3. Untamed Parrot Johnette: 1. Okg crumbs, 2 hearts, flying 1. Feed 2. Command 3. Play 4. Hit 5. Quit Choice: 1 Which parrot? 2 How much? 1.3 You tamed Nancy! 1. Tamed DEAD Parrot Julius: 2.1kg crumbs, 9 hearts 2. Tamed Parrot Nancy: 1.9kg crumbs, 2 hearts, flying 3. Untamed parrot johnette: 1.0kg crumbs, 2 hearts, flying \begin{tabular}{l|l|l|l|l|l|} 1. Feed 3. Cormand 3. Play & 4. Hit \\ 2. \end{tabular} Choice: 2 Which parrot? 1 Fly of stay? stay If's stone deadi' 1. Tramed DEAD Parrot Jullus: 2.1kg crumbs, 0 hearts 2. Tamed parrot Nancy: 1.9kg seeds, 1 heare, t1ying 3. Untaned parrot Johnette: 1.0kg seeds, 2 hearts, flying IMPORTANT BASIC RULE \#2: The main method is the view. It talks to the user, calls the appropriate Parrot methods in response to the user's input, and displays the results. It does not determine the results of a user's actions or keep track of anything. That's the job of the Parrot objects. Error Handing If the user makes a mistake (feeds a negative amount of seeds, asks a Parrot to play with a dead Parrot, etc.) this should be reported to the user. But remember, the ParrotCraft class does not implement any logic to decide what happened, and the Parrot class is not allowed to use System.out. Extra challenge: implement your code in the animate method of the EXAn imationTemplate instead of in a ma in method. You will still get input from the user in the console, but you can show the Parrots on the canvas, See GraphicsExampleEorAssignment2. Java for an example of this way of using animate

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

The best story ideas can often be expressed with

Answered: 1 week ago