Exam 3- 2011

Should initialize an instance variable for each type

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: g types of coins: • Pennies: worth 1 cent ($0.01) each • Dimes: worth 10 cents each • Quarters: worth 25 cents each No methods in this class should use input() or print()! Your class should be named CoinPurse, and you should define the following methods: __init__: This method initializes the coin purse. Parameters: 3 parameters for the initial contents of the purse  ­ ­ the number of pennies, dimes, and quarters. • Should initialize an instance variable for each type of coin using the values that are passed to it. get_total: Returns the total amount of money in the purse, in dollars. add_money: • Parameters for the numbers of pennies, dimes, and quarters to add to the current amounts in the purse. • Updates the amounts in the purse. • Does not return anything. pay: • Parameters for the numbers of pennies, dimes, and quarters to remove from the purse. • Updates the amounts in the...
View Full Document

This note was uploaded on 02/08/2014 for the course CS 115 taught by Professor Staff during the Fall '08 term at Sonoma.

Ask a homework question - tutors are online