Project #4 CMSC 131
Due Tuesday 10/18/05 at 11:00 PM Object-Oriented Programming I
Type of project: Closed Fall 2005

Objective

To practice writing classes and JUnit test cases.

Overview

For this project you will write two classes, Tiger and Trainer.  You will also write an extensive set of JUnit tests, which should test all of the methods you have written in your classes.  This project is different from most projects in this course, because there is no main() method anywhere.  What you are creating are two re-useable modules (Tiger and Trainer) that could later be made part of a complete program.

Put all of your work (Tiger.java and Trainer.java) in the folder we have provided labelled "src".

Tests


Writing the Classes

We are leaving many decisions about the implementation of these classes for you to decide.  DO NOT post questions on the wiki about how these choices should be made.  (Obviously your questions about how to make these decisions are welcome during office hours; we will guide you, but we will not explicitly tell you what to do.)  Below are descriptions of the two classes you must write.

Tiger Class

The "state" for a Tiger object contains three fields, described below.  You may also include any static constants that you think are useful.

The methods you must write are described below.  As mentioned previously, we are intentionally leaving a lot of decisions about how to write these methods for you to decide.  In particular, you must decide which of these things (if any) should be static.  In addition to the methods below, please feel free to also include as many private methods as you find useful.

Public methods

Private methods

Trainer Class

The "state" for a Trainer object contains two fields, below.  You may also include any static constants that you think are useful -- if you do, keep them private.

The methods you must write are described below.  As mentioned previously, we are intentionally leaving a lot of decisions about how to write these methods for you to decide.  In particular, you must decide which of these things (if any) should be static.  In addition to the methods below, please feel free to also include as many private methods as you find useful.

public methods

private method

 

Requirements

 

Grading

Your grade will be determined as follows:

 

Challenge Problem

Add a method to the Tiger class with the following prototype:

    public String lazySpeak(String message, int n)

The return value should consist of the concatenation of every nth word from the message.  In other words:  If n = 3, and the message is "This is my message.  How are you doing today?  I hope you are doing well."  Then the return value should be the String "This message. you I are". 

Note:  There could be arbitrarily many spaces between words in the parameter.  In your return String you may have any number of spaces between words, including 0.

If you do the challenge problem this time, please submit JUST ONE version of your project as usual.

Web Accessibility