Question: Here are some general guidelines to follow when implementing your solution to this assignment. a. Put of your code into a package named chickens.
Here are some general guidelines to follow when implementing your solution to this assignment. a. Put of your code into a package named "chickens". b. Use proper encapsulation. Only write accessors and mutators as needed. c. You must write unit tests for all classes and non-trivial methods, e.g. you do not need to write tests for accessors and mutators (though you may use them in your other tests). 1. Create a new Java type to represent the color of a chicken egg. Given that chicken eggs come in one of only two colors, consider the best way to create a type that may only have one of a specific list of predefined values.. 2. Create a new Java type to represent the size of a chicken egg. Chicken eggs come in one of six sizes, each of which has a minimum weight in ounces. Given a value of this new type, it should be possible to get the minimum ounces. For example, an Extra-Large chicken egg should be 27 ounces. 3. Create a new Java type to represent an egg. A chicken egg has the following attributes/methods: a. Eggs are created with a color and size. New eggs are uncracked. b. An egg may be cracked. Once cracked, an egg cannot be uncracked. c. The string representation of a chicken egg is formatted like this example: "An uncracked LARGE (240z) BROWN egg". d. Two eggs are considered equal if they are the same size and color, and are both cracked or uncracked. For example, two large, brown, uncracked eggs would be considered equal. Two peewee, white eggs would not be equal if only one of the eggs was cracked. 4. Create a new Java type to represent a chicken. A chicken has the following attributes/methods: a. A chicken has a name and always lays eggs of the same size and color. For example, a chicken named "Henny Penny" always lays large, brown eggs. b. The string representation of a chicken is formatted like this example: "Henny Penny, a that lays JUMBO WHITE eggs". c. Two chickens are considered equal if they lay eggs of the same size (regardless of the color) d. The Chicken class should include a static method to generate a chicken with a random. name, egg size, and egg color. You must select from at least 10 unique names. It is up to you what names to use. Do not worry about testing this method. 5. Create a ChickenFarm class that defines a main method with the appropriate signature. Prompt the user to enter how many chickens are on the farm. Use the static method on the Chicken class to generate the corresponding number of chickens. Print the string representation of each chicken and the first egg that it lays to standard output (see the output examples below). Note that, because the name selection for each chicken is random, you may have two or more chickens with the same name. 6. Use the drawing tool of your choice to draw a UML class diagram of the entire program. It should contain at least 5 classes or other types. Make sure to include the appropriate relationships between the types. Save your diagram as an image file in your repository and push it to GitHub along with your solution. Sample Run: Enter the number of chickens on the farm: 7 Chicken Little, a chicken that lays EXTRA LARGE WHITE eggs, laid An uncracked EXTRA LARGE (27oz.) WHITE egg. Hillary Fluff, a chicken that lays MEDIUM WHITE eggs, laid An uncracked MEDIUM (21oz.) WHITE egg. M-egg-atron, a chicken that lays EXTRA LARGE BROWN eggs, laid An uncracked EXTRA LARGE (27oz.) BROWN egg. Eggatha Christie, a chicken that lays SMALL WHITE eggs, laid An uncracked SMALL (18oz.) WHITE egg. Sal Monella, a chicken that lays LARGE BROWN eggs, laid An uncracked LARGE (24oz.) BROWN egg. M-egg-atron, a chicken that lays MEDIUM BROWN eggs, laid An uncracked MEDIUM (21oz.) BROWN egg. Optimeggs Prime, a chicken that lays JUMBO WHITE eggs, laid An uncracked JUMBO (30oz.) WHITE egg.
Step by Step Solution
3.47 Rating (163 Votes )
There are 3 Steps involved in it
1 package chickens public class Chicken private String name private int age private EggColor egg... View full answer
Get step-by-step solutions from verified subject matter experts
