Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please read carefully and use java; I need all the files. and please help with the javadoc also. Thank you. Problem Description After a long

image text in transcribedimage text in transcribedimage text in transcribed

please read carefully and use java; I need all the files.

and please help with the javadoc also.

Thank you.

Problem Description After a long night as band manager, you decide you want coffee, but the closest coffee shop is wildly inefficient Therefore, you decide to build a Cup class, a CoffeeMachine class, and a Drink enum Solution Description The Drink Enum Contains 'CHOCOLATE', COFFEE, TEA' and EMPTY' as possible values The above should have the following name and price (instances variables with the correct types) CHOCOLATE is named "hot chocolate" with price 1.50 COFFEE is named "coffee" with price 2.00 TEA is named "tea" with price 1.00 EMPTY is named "nothing" with price 0.00 Be sure to use proper convention when creating getters! More information about enums: Enums are like classes with a set number of instances. For instance, if you made a color enum with values RED, GREEN and BLUE, you would not be able to create a new YELLOW instance of color Because enums are types of classes, we can write constructors for enums. However, all instances are created within the enum class, so the constructor will be private. So, we must call the constructor when declaring the instances of the enum. Enums can also have instance fields and methods, written as you would for any other classes. Here's an example: public enum Size S (" small", M("medium), L("large") String name; private Size(String ne){ this.name name; public String getNameO return this.name On line 2 above you see constructor calls after each instance of the enum is declared. This enum has three instances called S, M and L that each have a 'name' instance field with values "small", "medium" and "large" respectively. Note that the syntax for the enum is exactly the same as that for any class after the line of instance declarations. The Cup Class Instance fields: A cup has a drink (from the Drink enum) and a stamp (indicating where that cup is from). The stamp should be immutable. Examples of stamps would be *Starbucks or Blue Donkey". These instance fields should have appropriate getters and setters (think about what immutable means) An equals method which checks if two cups are equals. Two cups are equal if their drink and stamp are the same. A toString method which returns a string with the cup's stamp and drink (using the Drinks name) in the format "A cup of [drink name] from stampl". For example: "A cup of coffee from Java The CoffeeMachine Class All members of this class should be STATIC. That means we have static variables and static methods! Keeps track of the number of cups, cupsUsed, the coffee machine has dispensed Keeps track of how much money, sales, has been made using the price of the drinks dispensed * Has a method named stats which prints that amount in the format Today we made amount earned and used [number of cups used" Stores up to 10 Cups at a time, cups, which is restocked when all the cups are given out (hint: how do you store multiple instances of a Class in a list wit hout imports) Contains a pour method, which takes in a cup and returns that same cup with whatever drink the user requested. If the user does not give the coffee machine a cup and only requests a drink, the coffee machine should take a cup from its 'stock' of cups and return that cup with whatever drink the user requested. If that stock is empty, it should be refilled. When refilling, the coffee machine's cups should all have the stamps "Java. Hemember For both the Cup and CoffeeMachine classes, think about private versus public modifiers (i.e. something should only be public if it ABSOLUTELY has to be). When do we use public and when do we use private? How do we ensure that we can access those private members of the class? Be efficient and avoid duplicate code whenever possible! Don't be afraid to add methods beyond the ones we require. This lets you to add a level of abstraction to your code. (Abstraction is the idea that a user should know what a method does and what it may give/return, but doesn't need to know how this is done). In this case, it'll probably be easier for you to write a program when everything isn't inside one method. Plus, this helps you reuse code! You will probably benefit from writing a tester class (i.e. Tester.java) with a main method that interacts with your CoffeeMachine class (and tests your other classes) to make sure all methods are functioning correctly Use proper convention when creating getters and setters! Allowed Imports To prevent trivialization of the assignment, you are not allowed to import anything. Feature Restrictions There are a few feat ures and methods in Java that overly simplify the concepts we are trying to teach. For that reason, do not use any of the following in your final submission: var (the reserved keyword) System.arraycopy System.exit Javaddocs For this assignment, you will be commenting your code with Javadocs. Javadocs are a clean and useful way to document your code's functionality. For more information on what Javadocs are and why they are awesome, the online overview for them is extremely detailed and helpful. You can generate the javadocs for your code using the command below, which will put all the files into a folder called javadoc: $ javadoc.java -d javadoc The relevant tags that you need to include are Cauthor, Oversion, Oparam, and Creturn. Here is an example of a properly Javadoe'd class: import java.util1.Scanner; This class represents a Dog object Cauthor George P. Burdell Oversion 1.0 public class Dog * Creates an avesome dog (NOT a dawg!) public Dog) This method takes in two ints and returns their sum Oparam a first number Oparam b second number Oreturn sum of a and b public int add(int a, int b) A more thorough tutorial for Javadocs can be found here. Take note of a few things 1. Javadocs are begun with/and ended with/ 2. Every class you write must be Javadoc'd and the Cauthor and Overion tag included. The comments for a class should start with a brief description of the role of the class in your program. 3. Every non-private method you write must be Javadoc'd and the Gparan tag included for every method parameter. The format for an Oparam tag is Oparam If the method has a non-void return type, include the Creturn tag which should have a simple description of what the method returns, semantically Checkstyle can check for Javadocs using the -a flag, as described in the next section. Just like Checkstyle, one point will be deducted for each Javadoc error detected by running dekstyle. TIese deductions will also be limited by the checkstyle cap, which applies to the sum of checkstyle and javadoc errors

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago