Question: This is my code --------------------- enum Flavor { Original, Diet, Zero, Cherry } // create Coke class class Coke { // private members boolean isDetected;

This is my code

---------------------

 enum Flavor { Original, Diet, Zero, Cherry } // create Coke class class Coke { // private members boolean isDetected; Flavor flavor; String blendName; String brandName; // constructors public Coke(String blend, String brand, Flavor fl, boolean isDetect) { isDetected = isDetect; blendName = blend; brandName = brand; flavor = fl; } public Coke(String blend, String brand, Flavor fl) { isDetected = false; blendName = blend; brandName = brand; flavor = fl; } public Coke(String blend, String brand) { isDetected = false; blendName = blend; brandName = brand; flavor = Flavor.Original; } // required methods public boolean is_detected() { return isDetected; } public Flavor getFlavor() { return flavor; } public String getBrandName() { return brandName; } public String getBlendName() { return blendName; } public boolean examine() { if (isDetected == true) { return false; } else { isDetected = true; return true; } } // here we are overridding toString method public String toString () { if(isDetected == false) return String.format("Brand: " + brandName + " " + "Blend: " + blendName + " " + "Flavor Type: " + flavor + " " + "Undetected"); else return String.format("Brand: " + brandName + " " + "Blend: " + blendName + " " + "Flavor Type: " + flavor + " " + "Detected"); } } public class Main { public static void main(String[] args) { // create Coke object Coke ob = new Coke("Happy Coke", "Happy 7911", Flavor.Zero); // use of overridden method toString System.out.println(ob); } }

---------------------------------------

Hello, my code is above. and I meet a problem. For main part "public class Main" at the bottom, I want to change the input ""Happy Coke", "Happy 7911", Flavor.Zero" to ("Happy Coke", "Happy 7911", Coke.Flavor.Zero) but it will show errors, what should I do to make it work, no need to learn about what's the subject, just help modify the code, Thanks.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!