Thursday, November 17, 2011

Reading in dates for Assignment 11

You will be testing your Datebook class by reading in a number of dates from a simple text file using the Scanner class. The text file is named dates.txt and can be found in the readonly -> files -> assignment11 folder on the class store. In order to do this testing, you should get the DatebookTest class from readonly -> files -> assignment11 folder on the class store and complete the start method to do the following. Create an empty datebook (which is actually done for you in the constructor for DatebookTest). Each date from the file should be added to your datebook. After reading all of the dates from the dates.txt file, print them out. Then delete the 4th date and print the dates out again. Then delete the last date in the datebook and print the dates out again. Finally, delete the first date in the datebook and print the dates out one more time. You will be creating an instance of DatebookTest and then invoking its start method. Record the output console from this interaction in the file interaction11.txt.

Monday, September 19, 2011

Concatenating Strings in Assignment 4

In order to compute the Item's id, you should use either the substring or charAt methods of the String class. Note that if you use charAt then you will be concatenating characters together. In this case, you will need to begin the expression by concatenating the empty string to the front of it. So, to concatenate the character 'b' to 'r' you would use the expression "" + 'b' + 'r'. To find out how to extract the first and last characters of a string, go to the Java API and check out the methods available for the String class. The first character is at position 0, but you'll need to compute the index of the last character.