Question
FILE OF RUNNER DOUBLECONE: import java.util.Scanner; public class runner_DoubleCone { public static void main(String[] args) { Scanner scan = new Scanner(System.in); DoubleCone c; System.out.println(Type s
FILE OF RUNNER DOUBLECONE:
import java.util.Scanner;
public class runner_DoubleCone {
public static void main(String[] args) { Scanner scan = new Scanner(System.in); DoubleCone c; System.out.println("Type \"s\" for same flavors, \"d\" for different."); String cons = scan.nextLine().toLowerCase(); System.out.println("Type \"w\" for waffle cone."); boolean w = scan.nextLine().toLowerCase().equals("w"); if (cons.equals("s")) { System.out.println("What flavour?"); String f = scan.nextLine(); c = new DoubleCone(f, w); } else { System.out.println("First flavour?"); String f1 = scan.nextLine(); System.out.println("Second flavour?"); String f2 = scan.nextLine(); c = new DoubleCone(f1, f2, w); } System.out.println(c); System.out.println("Change flavors? (y)"); if(scan.nextLine().toLowerCase().equals("y")) { System.out.println("Type \"s\" for same flavors, \"d\" for different."); String mtd = scan.nextLine().toLowerCase(); if (mtd.equals("s")) { System.out.println("What flavour?"); String f = scan.nextLine(); c.setFlavor(f); } else { System.out.println("First flavour?"); String f1 = scan.nextLine(); System.out.println("Second flavour?"); String f2 = scan.nextLine(); c.setFlavor(f1, f2); } System.out.println(c); } }
}
FILE OF CONE:
public class Cone {
private String flavor; private boolean waffle;
public Cone(String f, boolean w) { waffle = w; flavor = f; }
public void setFlavor(String f) { flavor = f; }
public String toString() { String s = ""; if (waffle) s += "waffle "; s += "cone with " + flavor; return s; }
}
Instructions Write a class which extends the class cone (which represents a cone with a single scoop of ice cream). Your class will be named DoubleCone, and will represent a cone with two scoops of ice cream. You will need to override all public cone methods in your subclass, plus you will overload both the constructor and the setFlavor methods. A summary of the methods in Cone and the methods you will write in Doublecone is in the table below. You should challenge yourself to rewrite as little code as necessary - try to call existing methods using super and this as much as possible. Method/Constructor signature Doublecone implementation Cone implementation Sets the ice-cream flavor to f and the waffle boolean to w. Cone(String f, boolean w) DoubleCone(String f, boolean w Sets both ice-cream flavors to f and the waffle boolean to w.. DoubleCone(String fi, String f2, boolean w) Sets the first ice-cream flavor to fi, the second to f2, and the waffle boolean to w. setFlavor (String) Sets the ice-cream flavor to f. Sets both ice-cream flavors to f. Sets the first ice-cream flavor to fi, the second to f2. setFlavor (String fi, String f2) returns a String representation of the ice cream with the flavor as shown by the 2 examples below: returns a String representation of the ice cream with the flavors (in order, first followed by second) as shown by the 2 examples below: toString cone with vanilla double cone with strawberry and peach waffle cone with chocolate double waffle cone with toffee and toffee You should test your code by running the main method of the runner class. Please do not edit the cone class, and do not add a main method to your DoubleCone.java file or your code will not be scored correctly. STATUS Files SAVE NOT SUBMITTED SUBMIT INST DoubleCone.java runner DoubleCone.java Cone.java SNMSMenos Files STATUS NOT SUBMITTED SAVE SUBMIT DoubleCone.java 1 - import java.util.Scanner; 2 3 public class runner_DoubleCone 4- { runner DoubleCone.java 6 7 Cone.java public static void main(String[] args) I Scanner scan = new Scanner(System.in); DoubleConec System.out.println("Type\"\" for same flavors, \"\" for different."); String cons = scan.nextLine().toLowerCase(); System.out.println("Type "w" for waffle cone."); boolean w = scan.nextLine().toLowerCase().equals("w"); if (cons.equals("s")) 9 19 10 11 12 12 13 1 14 14 15 15 16 17 17 10 18 10 19 20 ge 28 System.out.println("What flavour?"); String f = scan.nextLine(); c = new DoubleCone(f, w); 3 else { System.out.println("First flavour?"); String f1 = scan.nextLine(); System.out.println("Second flavour?"); String f2 = scan.nextLine(); C = new DoubleCone (fi, f2, w); } System.out.println(c); System.out.println("Change flavors? (y)"); if(scan.nextLine().toLowerCase().equals("y")) { System.out.println("Type "s" for same flavors, V for different."); String mtd = scan.nextLine().toLowerCase(); if (mtd.equals("s")) { System.out.println("What flavour?"); String f = scan.nextLine(); c. setFlavor(f); } else { System.out.println("First flavour?"); 30 31 - 39 Files STATUS NOT SUBMITTED SAVE SUBMIT DoubleCone.java runner DoubleCone.java I Cone.java 1 public class Cone 2-{ 3 4 private String flavor 5 private boolean waffle; 6 7 public Cone(String f, boolean w) 8 { 9 waffle = w; 10 flavor = f; ) 12 13 public void setFlavor(String f) 14 { 15 flavor = f; 16 } 17 18 public String toString() 19- { 20 Strings = ""; 21 if (waffle) 22 s += "waffle "; 23 5 += "cone with + flavor; 24 return si 25 26 27 28Step 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