CS 1120 Spring 2013LA 3 (Part II)University of Li

Lab Assignment 3 (Part II)
University of Li

Concepts

  • Inheritance
  • Method Overriding

Note: If you are in the Thursday lab, you will need to create the Student class from Part I (last week’s in-lab assignment). See the assignment description for how to do this.

Problem Specification

As described in Part I, in order to get a degree from the University of Li, all students – both undergraduate and graduate – need to earn a minimumof 30 credits. In addition, undergraduate studentsmust complete 20 hours of community service, and graduate students must publish two papers. Also, typically a student’s graduation date is set for the following May 1st; however, graduate students may also graduate on January 1st (whichever is sooner).

You will be adding to your project from last week by extending the Student class – with GradStudent and UndergradStudent – and incorporating the GraduationAuditor class, which is used to audit a list of students and set their graduation dates.

Design Phase

This week’s Design Phase does not explicitly tell you all of the attributes and methods you will need to create. Instead, it walks you through determining this for yourselves.

Work with a partner, following the design process outlined here. You must each individually submit a hard copy of the Design Phase of your lab report by the end of lab today.

Basic Structure

First think about the overall structure of the program. In your lab report, under Basic Structure, describe how the classes Student, GradStudent, and UndergradStudent are related (i.e. which are base or superclasses, and which are subclasses?).

List the Student class along with its attributes and methods described in LA3 (Part I). The other two classes will inherit all of Student’s attributes and methods, and will likely add their own attributes and methods, or override the existing ones with more specific implementation. For each type of Student, think about thepieces of information that only it needs. For example, does a GradStudent object need to keep track of hoursCommunityService? Add the two subclasses and any new attributes eachone needs to your report.

In Part I, the Student class had the takeCourse method, which would print out the course name and credit value, and add credits to the student’s total. Similarly, the two new subclasses will need methods which update the new data they track and print out a similar message. Add these methods along with brief descriptions of what they do to your report.

Look over the methods defined in the Student class. For each subclass, determine whether each method needs to be overridden or if the default behavior will work. Indicate which methods should be overridden for each subclass in your report.

Pseudocode

The steps below will ask you to write pseudocode or answer a question. Do this in your lab report.

  1. Choose two of the methods either newly added or overridden. Write pseudocode for them.

Implementation Phase

If you have not done so already, follow the Implementation Phase from LA3 (Part I) to create the base project. Some additional notes:

  • The determineGraduationDate method should only return a String indicating the appropriate date – it should not print anything.
  • Likewise, the meetsRequirements method should return a boolean indicating whether or not the appropriate requirements have been met – it should not print anything either.
  • You should provide a toString method for Student, which returns a String including the first and last name, and ID number. This method is useful for controlling how a particular object should be printed.

Add the new subclasses – GradStudent and UndergradStudent – along with their attributes and methods. Remember that you only need to implement newly defined and overridden methods (the others are automatically inherited).

Add constructors to each subclass, using the super keyword to utilize the superclass’s constructor.

Add to your project the GraduationAuditor class, which will be given to you. You should not make any changes to this class. That is, make sure your methods match up in terms of parameters and return values – don’t change how GraduationAuditor works to fit your methods.

Hints

For using Dates in Java, refer to the hints in LA3 (Part I).

Use constructors to initialize data in objects. That is, don’t make the object acquire the data itself (either through asking the user or reading a file). In your main method, you may hardcode this data when instantiating objects, like this:

UndergradStudent[] undergrads = new UndergradStudent[3];

undergrads[0] = new UndergradStudent(“Blanche”, “Graves”, “111”);

undergrads[1] = new UndergradStudent(“Mercedes”, “Patton”, “222”);

...

(Feel free to read this data from a file instead, if you want to go above and beyond – please just don’t make us type all the data in ourselves when we test your programs).

Testing Phase

Test your project by creating two different arrays – one of GradStudents and one of UndergradStudents. Instantiate at least 3 of each type of student, and call your methods to add course credits, community service, and papers written. Then call the performAudit method in GraduationAuditor twice, passing in first one array, then the other. This method should give you output similar to the example output below.

In your lab report, discuss how you tested your project and show your output.

Example Output:

...

Blanche Graves (ID 111) will graduate on 5/1/2013.

Mercedes Patton (ID 222) cannot graduate yet.

Adam Snyder (ID 333) cannot graduate yet.

Ed Simon (ID 5555) will graduate on 5/1/2013.

Colleen Parsons (ID 6666) cannot graduate yet.

Deborah Hudson (ID 7777) will graduate on 5/1/2013.

...

Maintenance Phase

Discuss what features could be added as the development cycle continues. What are some issues that could potentially arise because the current application does not account for certain situations or behaviors? These can be feature-related or structural weaknesses.

Assignment Submission

  • Generate a .zip file that contains all of your files, including:
  • Program Files
  • including any input or output files
  • The lab report document (including the design phase you completed during lab)
  • Submit the .zip file via E-learning
  • Submit a hard copy of the lab report at the beginning of your next lab