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:
- Use both value returning and void methods.
- Precisely follow specifications for methods.
- Use a generic driver to "exercise" your programs.
- Do everything necessary to
create, debug, and run a java program.
- Use comments to delineate
each section of the program.
- Adhere to a Style Guide.
- READ
AND FOLLOW DIRECTIONS!!!!!
Deadlines
- Submit: October 8th, 2013
by
11:59pm.
- Programs will not be accepted after 6 days late.
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
- 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.
- 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.
- 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.
- readLine - this method will take in a String prompt, display the prompt, read in a whole line from the keyboard.
- 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".
- 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".
- 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".
- 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".
- 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".
- 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".
- 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
- You must use the method headers as provided in the Toolkit.java
file.
- Your program must conform to
standard Java programming standards and the additional standards for
this class. See the Style Guide for your class.
- 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
- Your program will be
evaluated both by its correctness and conformance to the required Style
elements.
- You will achieve a grade of
70 pointsfor a program that runs correctly
and produces exactly the required output in the required format on time. This will be evaluated by WebCAT.
- You should provide a "main" program called MyTester which
contains at least one call to each method. You will not submit
this file to WebCAT, but will upload it to the Canvas assignment. I will not evaluate MyTester for conformance to the Style Guide as it is
a tester for your use only. The examples in MyTester should be different than the examples in the ToolkitTest.java program.(10 points)
- The remainder (20 points)
will be
based on your conformance to the Style Guide and other requirements of the
assignment. Review the Style
Guide before submitting your
program.
- All grades will be based on
100 points.
- You may submit any number of
times. The only one I will count is the one that corresponds to the
hardcopy report that you turn in.
- The hardcopy that you turn
in will be the formatted version that
I will check. Make sure it has no line wraps or other spacing
issues.
- Successfully submitted
programs that are late will be graded, then the late penalty is
assessed for each day late according to the following schedule.
For
submissions after:
- Oct. 8 - 10 points
- Oct. 9 - 20 points
- Oct. 10 - 30 points
- Oct. 11 - 40 points
- Oct. 13 - 50 points
- Oct 14 - 100 points
HINTS
- Begin early.
Students run into trouble by waiting too long to start the
program.
- Write and test one method at a time. Get it working well
(using your MyTester), then move on to the
next method.
- Understand the problem at
hand. Make sure that you follow
the requirements precisely. Don't add additional
"flourishes".
You will be downgraded.
- In the body of your main
method, outline your steps with comment lines for each part of the
project.
- If you wish to use additional methods to break up your code, feel
free to do so.