CS139 Algorithm Development

Software Requirements Specification

Programming Assignment 2

Toolkit

Due Tuesday, October 8th by 11:59pm


Introduction

Purpose: You have written enough code now to begin to see some patterns in what you need to do.  For example, when reading in a value from the keyboard, you prompt and then read the value. This program is the start of a toolkit that you can use with any future programming assignments or labs. Some of the String manipulation methods will be used in PA3 (See Chapter 10 for some handy methods). This is an example of a different PA3 than you will do, but it is similar and shows how some of the methods would be run. See the dialog for what is input and then how some of the methods you are building are used in that program. PA3_Sample

Objectives - At the conclusion of this exercise the student will demonstrate that they can:

Deadlines

Prerequisites

You have covered the material in Chapter 5 of Gaddis.  

Program Behavior

The driver program, ToolkitTest.java, contains a testing methods that will create a new Toolkit object, run each of its methods, and produce output that indicates whether your methods conformed to the expected behavior.  Method headers containing the name of the method, input parameters, and return type are found in the file, Toolkit.java.

Toolkit Methods

  1. readInteger - This method will take in a String prompt, display the prompt, read in the value from the keyboard and return the result. This method should consume the newline character.
  2. readDouble - This method will take in a String prompt, display the prompt, read in the value from the keyboard, and return the result.. This method should consume the newline character. 
  3. readToken - This method will take in a String prompt, , display the prompt, read in the value from the keyboard. This method will read in only the next token (set of characters before a white space character).This method should consume the new line character.
  4. readLine - this method will take in a String prompt, display the prompt, read in a whole line from the keyboard.
  5. makePluralS - This method will take in a String and return that String with an 's' appended to the end. If I called this method with "textbook", the method would return "textbooks".
  6. makePluralIes - This method will take in a String and return that String with the last letter removed and an 'ies' appended to the end. So for example, if I sent in the String, "body", this method would return "bodies".
  7. makePluralEs - This method will take in a String and return that String with "es" appended to the end. If I called this method with "dish", it would return "dishes".
  8. capitalize - This method will take in a String and capitalize the first letter of the String. For example, if I sent in the String "penguin", the method would return "Penguin".
  9. makeSmall - this method will take in a String and make all letters of the String lower case. For example, if I sent in the String "PenGuin", the method would return "penguin".
  10. makePossessive - this method will take in a String and return the String with "'s" appended to the end. If I sent in the String, "student", this method would return "student's".
  11. makePossessiveS - This method will take in a String and return the String with "'" appended to the end. If I sent in the String, "students", this method would return "students'".

Examples

Method call (assumes a Toolkit object named bob) Display Input (for get methods) Return value
bob.readInteger("Enter an integer: "); Enter an integer:

5 5
bob.readDouble("Enter a double number: "); Enter a double number: 5.75 5.75
bob.readDouble("Enter a double number: "); Enter a double number: 5 5.0
bob.readToken("Enter a word: "); Enter a word: something "something"
bob.readToken("Enter a word: "); Enter a word: something else entirely "something"
bob.readLine("Enter a message: "); Enter a message: This is silly "This is silly"
bob.makePluralS("chair"); "chairs"
bob.makePluralIes("butterfly"); "butterflies"

bob.makePluralIes("chainsaw");

NOTE: this doesn't make sense, but that is what the method should do.

"chainsaies"
bob.makePluralEs("annex") "annexes"
bob.capitalize("butterfly"); "Butterflies"
bob.capitalize("CS139"); "CS139"
bob.makeSmall("CS139"); "cS139"
bob.makeSmall("Harris"); "harris"
bob.makePossessive("Norton"); "Norton's"
bob.makePossessiveS("Profs"); "Profs'"

Output

    The only output you must worry about in this PA is the output of the readInteger(), readDouble(), readToken() and readLine() methods. For these methods, the output should be of the form:

    prompt message where the prompt message is the value passed to the method.

All other output will be done for you in main. (Cheers all around!)

See the sample output document for what the JGrasp session might look like when running the tester program.

Sample output: out.txt

 

Error Handling

You do not need to be concerned wtih Error Handling in this PA.

Additional Program Requirements

  1. You must use the method headers as provided in the Toolkit.java file.
  2. Your program must conform to standard Java programming standards and the additional standards for this class. See the Style Guide for your class.
  3. You must create a program called MyTester which will be test each method with at least one value (you will simply need to call the getInteger, etc methods and echo their output, but for the others you should use and print sample data similar to what we do in the ToolkitTest.java program that we provide.  You should display the results of those tests (using a print statement).

Honor Code

This work must conform to the JMU Honor Code and the specific requirements of this class. NO help may be provided by any student to another student. This is an individual PA. Authorized help is limited to your textbook, the TAs for any CS139 or CS239 section, and the professor for your section. See collaboration policy.

Grading

        For submissions after:

HINTS