Assignment 1

Be sure to type up your answers so you can submit them electronically on the BlackBoard Connect system. You may complete this assignment individually. Make sure all your files have your full name and student number on it.

Type up your answers using Eclipse. The file format of the Java program you are to submit must be .java.

This assignment is marked out of 55 points.

Due Date

January 25, 2014, 11:59AM (just before noon).

24 Hour Silence Policy

Due to the large class size and the potential volume of questions, we are implementing a 24-hour silence policy. This means that any questions posted on the discussion forum in the 24 hours immediately preceding the assignment deadline may not get answered in time. This does not mean that we will stop answering questions the moment the day before the deadline arrives, it just means that we cannot promise all the questions will be answered in time, due to our prior engagements, such as other classes and meetings we have.

For this reason, please be sure to attempt the assignment early, and try to complete it as if it were due two days prior to the real deadline.

In any case, we will try to answer all the questions that show up on the discussion forum. Note that questions sent to emails will not be answered, as we want all course related material to be viewed for everyone's benefit.

What You Are Given

There are 2 questions in this assignment. The first question is to review some major concepts that you should be familiar with from COSC 111. The second question gets you to practice inheritance.

Question 1 [30 points]

In this question, define a class called GradesTracker that helps a student keep track of his/her course grade so far. The data we keep track of will be modeled based on the COSC 121 evaluation criteria. That is, we will have 3 assignments that are worth 20% (weighted equally), 9 labs that are worth 20% (weighted equally), 1 midterm that is worth 20%, and a final exam that is worth 40%.

The criteria used to evaluate your solution for this class are:

5 points: Don't forget to test your program. Write a test class called TestGradesTracker that creates a GradesTracker object, lets the user enter grades, calculates the course grade, and prints out the computed grade on the screen.

Do the following four test cases for your code to ensure your program works:

  1. Testing to get your mark just before the final exam
    Enter all assignment marks, all lab marks, and midterm mark. Compute course grade.
  2. Testing to make sure it works even if no marks are available
    Don't enter any marks for anything. Compute course grade.
  3. Testing to get marks so far if only one set of marks are available
    Enter all assignment marks, but nothing for the others. Compute course grade.
  4. Testing to get overall mark when some marks are available
    Enter two assignment marks, 5 lab marks, a midterm mark, and a final exam mark. Compute course grade.
See sample output for these cases. When you test your program, be sure to include these 4 cases in your output. Save your output into a file called Grades-Output.txt.

Question 2 [25 points]

4 points: Define a class called Reading that keep track of the number of pages, year of publication, and the title. This class will serve as the parent class for the others you will define below. Be sure you do the following: Next, define three classes that model various types of readings named as followed: Novel, Textbook, and Newspaper. Each child class will also need to handle the following: Each class definition will be worth 5 points each.

Make sure you put shared variables and methods in the parent class. You may wish to use super and protected as needed. Also, be sure to not have shadowing variables in your classes.

  • 3 points: Don't forget to follow encapsulation rules.
  • 3 points: Write a test class called TestReading that creates an object for each of the child classes defined above. You should demonstrate your classes work by printing out the information in each of these readings, then changing some of the information via mutators, and re-printing those objects to show the changes have been made. You can see the sample output provided here. Save your output into a file called Reading-Output.txt.

    What to Submit

    Be sure to comment all the methods and attributes for clarity. For this assignment, submit the following: