Lab Assignment 3 Inheritance Solution

$30.00

Description

Objectives

Review inheritance

Review polymorphism

Review overriding superclass methods

Problem Specification

Develop a Java application that creates student profiles, updates the profiles with relevant information (personal and school-related), performs required processing of the data to determine if each student has met the graduation requirements, and prints out this information to the console. The different types of Student are undergraduate as well as graduate students.

To be eligible for graduation, all students – both undergraduate and graduate – need to earn a minimum of 30 credits. In addition, undergraduate students must complete 20 hours of community service, while graduate students must publish two papers.

Your program should also be able to audit an array of students and determine whether each student can graduate or not.

The application should exhibit the following functionality (see the sample output provided):

Display the “type” of students to be audited Display the following for each student:

  1. the name of the student,

    1. List of courses taken and the corresponding number of credits for each course o Number of credits accumulated for corresponding courses

o Number of hours of community service (for undergraduates only) o List of publications (graduate students only)

The results of the “audit” process for that student (i.e., can a student graduate yet or not). This comes after displaying the data for all students

A sample output (to be followed exactly) is included below. Since the test class is provided, the output from your program should be exactly the same as the one below.

1

CS 1120 LA3 Inheritance

Undergraduate Students:

=======================

Blanche Graves

==============

Course taken: Intro to Java (26 credits)

Course taken: Intro to Computing (8 credits)

Credits completed 34

Hours of community service: 40

Mercedes Patton

==============

Course taken: Intro to Java (15 credits)

Course taken: Intro to Computing (8 credits)

Credits completed 23

Hours of community service: 15

Graduate Students:

==================

Elizabeth Bennett

==============

Publication #1: The Meaning of Life

Publication #2: Living Free

Course taken: Intro to Java (26 credits)

Course taken: Intro to Computing (8 credits)

Credits completed 34

Number of Publications: 2

David Copperfield

==============

Publication #1: The Meaning of Life

Course taken: Intro to Java (15 credits)

Course taken: Intro to Computing (8 credits)

Credits completed 23

Number of Publications: 1

Audit results:

==============

Blanche Graves can graduate

Mercedes Patton cannot graduate

Elizabeth Bennett can graduate

David Copperfield cannot graduate

Design Requirements

  • Use the following class names: Student, UndergradStudent, GradStudent, and GraduationAuditor (for the class determining graduation).

2

CS 1120 LA3 Inheritance

  • You are required to use the following StudentTest class for testing your program. Notice that no user input is required as all data for the students are hard-coded into the test class.

public class StudentTest {

public static void main(String[] args) {

  • TODO Auto-generated method stub GraduationAuditor auditor = new GraduationAuditor();

System.out.println(“\nUndergraduate Students:”);

System.out.println(“=======================\n”);

UndergradStudent[] undergrads = new UndergradStudent[2];

// Student #1

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

System.out.println(undergrads[0].getName());

System.out.println(“==============”);

undergrads[0].doComunityService(20);

undergrads[0].doComunityService(20);

undergrads[0].takeCourse(“Intro to Java”, 26);

undergrads[0].takeCourse(“Intro to Computing”, 8);

undergrads[0].printData();

System.out.println();

// Student #2

undergrads[1] = new UndergradStudent(“Mercedes Patton”, 222); System.out.println(undergrads[1].getName()); System.out.println(“==============”); undergrads[1].doComunityService(15); undergrads[1].takeCourse(“Intro to Java”, 15); undergrads[1].takeCourse(“Intro to Computing”, 8); undergrads[1].printData();

System.out.println(“\nGraduate Students:”);

System.out.println(“==================\n”);

GradStudent[] grads = new GradStudent[2];

// Student #3

grads[0] = new GradStudent(“Elizabeth Bennett”, 111);

System.out.println(grads[0].getName());

System.out.println(“==============”);

grads[0].publishPaper(“The Meaning of Life”);

grads[0].publishPaper(“Living Free”);

grads[0].takeCourse(“Intro to Java”, 26);

grads[0].takeCourse(“Intro to Computing”, 8);

grads[0].printData();

System.out.println();

// Student #4

grads[1] = new GradStudent(“David Copperfield”, 222); System.out.println(grads[1].getName()); System.out.println(“==============”);

3

CS 1120 LA3 Inheritance

grads[1].publishPaper(“The Meaning of Life”); grads[1].takeCourse(“Intro to Java”, 15); grads[1].takeCourse(“Intro to Computing”, 8); grads[1].printData();

System.out.println(“\nAudit results:”);

System.out.println(“==============\n”);

auditor.audit(undergrads);

auditor.audit(grads);

}

}

Hints

  1. As discussed in class, subclasses inherit the public members of their superclasses. Any actions that are processed in the same manner for both UndergradStudent objects and GradStudent objects, should be performed by a method in the superclass.

  2. Actions that are specific to a particular subclass should be processed in a method in the subclass.

NOTE:

You will need to show an example of method overriding in this lab assignment. Think of a task that can be performed on Student objects (even if that task needs to be more specialized for the subclasses). Include a method to perform that task in the superclass (Student) and, in the subclasses, provide methods to override the superclass method.

The code provided for the test class is not to be modified. If your program does not work with the code provided, significant points will be lost.

Additional Requirements

Software Life Cycle Report with UML diagrams

You are required to follow the Software Life Cycle (SLC) methodology presented in class, and write the SLC Report, explaining how you followed the nine phases of the Software Life Cycle in this assignment.

For this LA, you are also required (for the first time) to provide the UML diagram for your application, showing all classes, their fields/attributes and the methods they provide. You should also show the class hierarchy. Your UML diagrams should be included in Part 1 of Phase 2 of your SLC. Please note that UML diagrams must be drawn using an appropriate program (e.g., MS Paint or MS Powerpoint).

A proper design (with stepwise pseudocode refinement), a proper coding method (with stepwise code refinement starting from the most detailed pseudocode refinement), and proper testing are all essential. For reference, please see the Sample SLC Report (covered in class) on Elearning.

Note: Correct pseudocode development will be worth 40% of the total LA3 grade.

4

CS 1120 LA3 Inheritance

Coding Standards

You must adhere to all conventions in the CS 1120 Java coding standards (available on Elearning for your Lab). This includes the use of white spaces and indentations for readability, and the use of comments to explain the meaning of various methods and attributes. Be sure to follow the conventions also for naming classes, variables, method parameters and methods.

Assignment Submission

Generate a .zip file that contains all your files including: o Program files

o Any input or output files

o The SLC Report (a text with description of all nine phases of the Software Life Cycle) Submit the .zip file to the appropriate folder on Elearning.

NOTE: The Elearning folder for LA submission will remain open beyond the due date but will indicate by how many days you missed the assignment deadline.

The penalty for late submissions as stated in the course syllabus will be applied in grading any assignment submitted late. Remember to turn in an LA even if not completed within 7 days after the deadline – since a student who does not submit 2 or more LAs will earn a failing grade in the class (even with perfect scores earned in the remaining LAs, exams, etc.)

5