Question
You will need to add the methods to the writingTool class: * Create a constructor class which will be take in all four properties *
You will need to add the methods to the writingTool class:
* Create a constructor class which will be take in all four properties * Create setters and getters for properties, except the dye level. Dye level can only be set in the constructor methods. The get dye level will exist and report the amount of dye remaining. * create a write method which when a string is passed for each character takes 1/1,000 of a dye level. Dye level cannot be negative. If the level is 0 and the write method is called, an error message is provided. The input will be taking from the scanner object and printed to the console. If a clear plastic shell, red colored, 100 leveled pen is used, the output to console will state "" Input. The beginning of output will state the writing tool used. * Print details method, prints the type of shell, the dye name, dye color and the dye level.
Create a new class which creates a red pen. work through all the permutations to test the red pen until you think you have all the code correct.
Next create another class which creates an art box of pens and pencils for each color we have defined. Thus you will create an array of writingTool to define everything.
Write in Java, here is the code needed to work with:
public class writingtool { private String shell; private String dye; private int dyeLevel = 0; private NamedColor dyeColor;
//Put class details here. public enum Color { RED, YELLOW, BLUE, BLACK, ORANGE, GREEN, BROWN, PURPLE; //each is an instance of Color } // end enum Color public enum NamedColor { BLUE(Color.BLUE, "Blue"), RED(Color.RED, "Red"), YELLOW(Color.YELLOW, "Yellow"), BLACK(Color.BLACK, "Black"), ORANGE(Color.ORANGE, "Orange"), GREEN(Color.GREEN, "Green"), BROWN(Color.BROWN, "Brown"), PURPLE(Color.PURPLE, "Purple");
private final Color awtColor; private final String colorName;
private NamedColor(Color awtColor, String name) { this.awtColor = awtColor; this.colorName = name; }
public Color getAwtColor() { return awtColor; }
public String getColorName() { return colorName; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started