1
Handout B
for
h07
CS56 W20

FreeCandy.java

1
2
3
4
5
6
7
8
9
10
public class FreeCandy implements Edible {

    private int calories;
    
    public FreeCandy(int calories) { 
	this.calories = calories;
    }

    public int getCalories() {return this.calories;}
}

Product.java

1
2
3
4
5
6
7
8
9
10
11
12
public abstract class Product {
    String name;
    int price;
    
    public int getPrice() { return price; } 
    public String getName() {return name;}

    public Product(int price, String name) {
	this.price = price;
	this.name = name;
    }
}
End of Handout