1. |
Answer: |

2. |
Now translate those informal descriptions into Java method signatures, such as Answer: |

3. |
What instance variables would you supply? Hint: You need to track the number of cans and tokens. Answer: |

4. |
Answer: |

5. |
Now supply a method fillUp(int cans) to add more cans to the machine. Simply add the number of new cans to the can count. Answer: |

6. |
Next, supply two methods getCanCount and getTokenCount that return the current values of the can and token counts. (You may want to look at the getBalance method of the BankAccount class for guidance.) Answer: |

7. |
Answer: |

8. |
Now test your class with the following test program. Answer: |

9. |
Answer: |

10. |
Answer: |

11. |
Now implement one of the classes in more detail. The left-hand side of the postcard is a Answer: |

12. |
Try out your class with the following test code: Answer: |

13. |
Answer: |

14. |
A null reference is used to indicate that an object variable does not refer to any object. You cannot invoke methods on a null reference since there is no object to which the method would apply. Answer: |