Introduction to Computer Science II for non-majors by James Tam |
Similar to the previous assignment: aside from the 'main' method you are not to write static methods for this assignment. (If you don't know what I'm referring to by static methods, I will be discussing this topic later in the course). Unlike the previous assignment you need to write multiple non-static methods for this assignment. (Unlike the previous assignment don't write all your functionality all in one method).
Okay:
public class Zodiac
public void startZodiac ()
{
}
}
Not Okay:
public class Driver
{
public static boolean
isDayValid ()
{
}
}
The requirements for this assignment are identical to the ones for Assignment 1 except that you must now employ two classes: 1) A "Driver" class (that contains the 'main' method) 2) Another class, "Zodiac", that implements the features described in the previous assignment. In Assignment 1 it was likely that your main method contained all of your program code. For the second assignment it is likely that your main method will now just instantiate an instance of class Zodiac and perhaps include a method call or two to an instance of class Zodiac:
public class Driver
{
public static void main (String [] args)
{
Zodiac aZodiac = new
Zodiac();
aZodiac.startZodiac();
}
}
With this assignment most or all the calls to the different methods of class Zodiac are contained in the "startZodiac" method of class Zodiac.
public class Zodiac
Method name |
Return Type |
Methods of class Zodiac called by this method |
Description |
Zodiac constructor | None | None | Initialize the month and day attributes to default starting values. If the instance of class Scanner is an attribute of Zodiac then it should be instantiated in the constructor. |
Introduction |
void |
Provides a brief overview of what the program does (user instructions). |
|
determineSign |
void |
None |
The month and day of birth attributes have already been entered by the user and validated by other methods before this method has been called. This method displays an appropriate message regarding the astrological sign based on the month and day of birth. |
isDayValid | boolean | None | Returns a true or false value depending upon the day of birth. |
isMonthValid | boolean | None | Returns a true or false value depending upon the birth month. |
promptDay | void | None | Displays an appropriate prompting message and gets the day of birth from the user (value is stored in the 'day' attribute). |
promptMonth | void | None | Displays an appropriate prompting message and gets the birth month from the user (value is stored in the 'month' attribute). |
startZodiac | void | promptMonth(), promptDay(), isMonthValid(), isDayValid(), determineSign() |
The starting point for this class and where most of the functionality gets invoked. However there should be very little code in this method, most of the code here will consists of calls to the other methods. |
For this assignment you are to write at least two test Drivers that evaluate the correctness of a part of your program: (1) one driver will test the correctness of one your branches (2) another driver will test one of your loops. You should include information about your tests in a text file called README. That file should indicate what part of your program is being tested (which loop or branch), what are the conditions being tested (e.g., obvious false case for a branch) and the data used for each test condition (e.g., x = -123). Make sure you submit the test drivers and the README file along with your assignment code. The TA's will go over examples of test drivers in tutorial during the week of Jan 29 - Feb 4 so that's where/when you can get detailed information about how to do this in your assignment.