-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMug.java
More file actions
57 lines (49 loc) · 1.46 KB
/
Copy pathMug.java
File metadata and controls
57 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package cafeCheckout;
import java.awt.*;
import java.util.Scanner;
/**
* This is a Mug class which is a subclass of TimsProduct
*
* @author Meet Patel
**/
public class Mug extends TimsProduct{
// color of the mug
private Color color;
// set the properties of the mug
private Mug(String name, Color color, double cost, double price) {
super(name, cost, price);
this.color = color;
}
// creates an object of Mug
public static Mug create() {
System.out.println(
"Please select your choice: \n" +
"1. Black \n" +
"2. Blue \n" +
"Your choice: "
);
// TODO: Fill in this stub to have a dialog with the user
Scanner sc = new Scanner(System.in);
int choice;
choice = sc.nextInt();
if(choice == 1) {
return new Mug("Black Mug", Color.BLACK, 2.00, 4.00);
}
else if(choice == 2) {
return new Mug("Blue Mug", Color.BLUE, 1.50, 3.00);
}
else {
System.out.println("Please choose correct option");
}
// and create a TimsOrder.
return null;
}
// return the color of the mug
public Color getColor() {
return color;
}
// print string
public String toString() {
return "Mug: " + super.toString() + "Color: " + color;
}
}