Pig + Candy
class Candy { private String maker; //e.g. Hershey’s, Willy Wonka private boolean isChocolatey; private double price; }
1. Write a constructor for this class.
2. Instantiate your favorite candy
3. Finish the Pig constructor.
class Pig { private String name; private boolean isSheepHerder; public Pig(String name, boolean canHerdSheep) { // write code here } public boolean willBecomeBacon() { if(this.isSheepHerder) return false; else return true; } } }
4. Instantiate two pigs, “Babe” and “Rasher”.
5. Imagine there is a pig instance called ziggy. Write code that will print “bacon for breakfast” if ziggy is destined to be turned into bacon, or “eggs for breakfast” if he is not.