CPS 109 Study Guide - Quiz Guide: Methionine, Subsequence, Reading Frame
Document Summary
In each of the following program files, the part that you had to write is between the and comments. A purse has an array of coin names. There is a method for adding coins and a tostring method for showing the coins in the purse public class purse. Constructs a purse with a default size. public purse() coins = new string[size] ; count = 0 ; @param size the size of the purse public purse(int size) coins = new string[size] ; count = 0 ; @return false if the coin cannot be added (the purse is full or the coin is not legal), otherwise true and the coin is added to the array coins public boolean addcoin(string coin) // 1. if there is no room or coin is not legal, return false ; if (count >= coins. length || !legal(coin)) return false ; //2. otherwise put coin at position count ; coins[count] = coin ;