CS 683 Emerging Technologies

Fall Semester, 2006

Assignment 3

Assignment Index

© 2006, All Rights Reserved, SDSU & Roger Whitney

 San Diego State University -- This page last updated 10/19/06

Due October 31

1. Add a method, "vowelsDo" to the string class. The method expects a block. The block has with one argument. The method will call the block once for each occurrence of any vowel in the string, passing each vowel to the block.

  

2. Add the method to_english to the Fixnum class. The method converts numbers between 0 and 3000 (including 0 and 3000) to the english equivalent. So for example we have

    11.to_english returns eleven

    45.to_english returns forty five

3. Write a BankAccount class. The class maintains a balance. The balance is initialized to zero when a BankAccount object is created. The class has three public methods: balance, deposit, withdrawal. "balance" returns the balance of the account. "deposit" and "withdrawal" both have one argument. If the argument is not a nonnegative number an exception is to be raised. "deposit" adds its argument to the balance. "withdrawal" subtracts it argument from the balance unless it would make the balance negative. In that case "withdrawal" throws an exception. Write unit tests for the class.

4. Let the character a represent 1, b represent 2, c represent 3 etc. The case (upper or lower) does not matter in this problem. The value of a word in the sum of the values of its characters. So 'abc' has the value 6. A dollar word is a word that has value 100. Add the method dollar_word to the string class that returns an array of the dollar words in the string. Words are separated by spaces. Provide unit tests.

5. Finals for Fall 2006 semester are over at 9:00 pm on Dec 16. Create a web page for Rails that when viewed informs the view how many days (as an integer) until the semester is over.