PRO192 Lab4
PRO192 Lab4
I don’t want to give you specific directions here to give you an opportunity
to decide what will work the best here to start describing the Sweet
hierarchy: an interface or an abstract class?
a. Candy, Lollipop and Cookie - three other types from Sweet hierarchy.
// the method returns copy of the Sweet[] array so that nobody could
// modify state of the present without addSweet() method.
// Also array shouldn’t contain null values.
public Sweet[] getSweets() {
<write your code here>
}
candy.setSugarWeight(0.53); lollipop.setName("Lollipop");
candy.setWeight(0.05); lollipop.setSugarWeight(0.2);
cookie.setSugarWeight(0.1); present.addSweet(cookie);
cookie.setDoughWeight(0.3); present.addSweet(lollipop);
cookie.setWeight(0.2);
Sample test:
<package>Q3: Interface
testDevice() method
public static void testDevice(Device device) {
basicRemote.power();
device.printStatus();
advancedRemote.power();
advancedRemote.mute();
device.printStatus();
Sample test: