Jan 8, 97 Correction: The following line in main has been changed Day d1, d2(3), d3('F', '1'); to Day d1, d2(3), d3('F', 'r'); CSE 9B UCSD Winter, 1997 Assignment 1 Due date: For turnin program: Midnight at the end of the day Tuesday January 14. For interview: End of the day Tuesday January 21. Reading: Chapter 6 and section 8.1 of Chapter 8 in the Savitch text Programming: This is a review of what we covered about classes in CSE 9A. You may work in teams of two people on this. You may work alone if you prefer. In this assignment, you will write definitions for a number of different classes. Read the instructions carefully. In one case you only need to give the class definition, but need not define the member functions. In other cases you must define all member functions. Here are some general details before we give you the specific details: >The file you turn in will contain all your class definition before main and all the member functions that you are required to give placed after main, plus the following main: int main() { cout << "Counter Test:\n"; CounterType c1, c2(100); c1.output(cout); cout << " should equal 0.\n"; c2.output(cout); cout << " should equal 100.\n"; c2.output(cout); cout << " should equal " << c2.get_count() << endl; c2.increment(); c2.output(cout); cout << " should equal 101.\n"; c1.decrement(); c1.output(cout); cout << " should equal 0. (Better not be -1.)\n"; c2.decrement(); c2.output(cout); cout << " should equal 100.\n"; for (CounterType c(1); c.get_count() <= 3; c.increment()) { c.output(cout); cout << " "; } cout << "Hurrah!" << endl; cout << endl << "Day Test:\n"; Day d1, d2(3), d3('F', 'i'); d1.output(cout); cout << " = Sunday\n"; d2.output(cout); cout << " = Wednesday\n"; d3.output(cout); cout << " = Friday\n"; d1 = d2.next(); d1.output(cout); cout << " = Thursday\n"; return 0; } Note that this main does not do anything except test the two classes CounterType and Day. >Do the classes one at a time. be sure one is correct and compiles without any errors before you go on to do the next class. This may require that you comment out part of main for a while. Note that you will get partial credit for each of the classes that are completed, but very little if any partial credit for a single class that is only partially completed. >Be sure to include pre- and postconditions with your member functions. Here are the classes you need to define. You need not give member functions unless you are explicitly asked to give them: CounterType Programming Project 4 of Chapter 6 on page 341 of the Savitch text. Except that we provide you with the names of the class members and the test program. You must define the class and MUST DEFINE ALL MEMBER FUNCTIONS for the class CounterType. member function names: increment -- increments the counter decrement -- decrements the counter get_count -- returns the current value of the counter output -- outputs the current value of the counter Note that this is essentially the same as Assignment 6 from CSE 9A. Month This is describe in Programming Project 5 of Chapter 6 of the Savitch text (pages 341-342). Note you do NOT have to give any member function definitions for the class Month. Also, you do NOT have to give any test program for the class Month. Day This is a class for a day of the week, such as Sunday, Monday, etc. For this definition think of the days as numbered Sunday is 0, Monday is 1, Tuesday is 3, ..., Saturday is 6. The class Day has the following member functions: A constructor with no arguments that initializes the day to Sunday. A constructor that takes one arguments which is assumed to be one of the integers 0 through 6 and which sets the day according to the integer. A constructor that takes two a parameters of type char that are assumed to be the first two letters in the name of some day. The constructor initializes the day according to the arguments. The constructor should work whether the arguments are in uppercase or lowercase letters. A function called next that returns the next day in the week. (Remember that every day has a next day.) A function called output that outputs the day to a stream. The day is output as a work such as "Monday" You must define ALL MEMBER FUNCTIONS for the class Day. It is fine to have long switch statements or long multibranch if-else statements.