Question: The objective is to practice building new classes: a. To define constructors. b. To define getter and setter methods. c. To build a new class

The objective is to practice building new classes: a. To define constructors. b. To define getter and setter methods. c. To build a new class from a super class. The two classes CsusStudent and Csc20Student specification (in UML notation ) are given below:

The objective is to practice building new classes: a. To define constructors.

-Develop your program according the pseudo code given in these classes. -Test your program by running the main method in Lab5Tester.

/////////////////////////////////////////////// Csc20Student.java below

// This class defines Csc20Student's profile with extension of CsusStudent // Provide more inputs here public class Csc20Student extends CsusStudent {

// attributes private boolean preComputerMajor; private int numberOfComputerClassUnits; // constructor public Csc20Student(String name, int id, String address, String phone, String email, boolean preCsMajor, int csUnits) { super(....); } // getPreComputerMajor public boolean getPreComputerMajor () { } // setPreComputerMajor public void setPreComputerMajor (boolean value) { }

// getNumberofCsUnits public int getNumberofCsUnits () { } // setNumberofCsUnits public void setNumberofCsUnits (int units) { }

// toSTring public String toString(){ // return a string value by combining all values from class's attributes }

}

//////////////////////////////////////// CsusStudent.java below

// This class defines CsusStudent's profile including: name, id, address, phone, and email // provide more inputs here

public class CsusStudent { // class attributes private String studentName; private int studentId; private String studentAddress; private String studentPhone; private String studentEmail;

// constructor public CsusStudent(String newName, int newId, String newAddress, String newPhone_number, String newEmail){ }

// setName public void setName(String newName){

}

// getName public String getName(){

} // setID public void setID(String newID){

}

// getID public String getID(){

}

// setAddress public void setAddress(String newAddress){

}

// getAddress public String getAddress(){

}

// setPhone public void setPhone(String newPhone_number){

} // getPhone public String getPhone(){

}

// setEmail public void setEmail(String newEmail){

}

// getEmail public String getEmail(){

}

// toString public String toString(){ // return a string value by combining all values from class's attributes

}

}

////////////////////////////////////////////// CsusStudentTest.java

// This Junit is used to validate student's assignment // It is also used to demostrate the functionality of Junit as student is first learning it.

import org.junit.Assert; import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test;

public class CsusStudentTest {

/** Fixture initialization (common initialization * for all tests). **/ CsusStudent instance; Csc20Student instance2; @Before public void setUp() { instance = new CsusStudent("John Doe", 123, "123 Somewhere", "415-555-1212", "johndoe@somewhere.com"); instance2 = new Csc20Student("John Doe", 123, "123 Somewhere", "415-555-1212", "johndoe@somewhere.com",true,15); instance = instance2; }

// test getName @Test public void testGetName() { String expResult = "John Doe"; String result = instance.getName(); assertEquals(expResult, result); }

// test getAddress @Test public void testgetAddress() { String expResult = "123 Somewhere"; String result = instance.getAddress(); assertEquals(expResult, result); } // test getPhone @Test public void testgetPhone() { String expResult = "415-555-1212"; String result = instance.getPhone(); assertEquals(expResult, result); }

// test getEmail @Test public void testgetEmail() { String expResult = "johndoe@somewhere.com"; String result = instance.getEmail(); assertEquals(expResult, result); } }

///////////////////////////////////////////////// Lab5Tester.java

// Lab5 tester class public class Lab5Tester { public static void main(String[] args) { CsusStudent student = new CsusStudent("John Doe", 123, "123 Somewhere", "415-555-1212", "johndoe@somewhere.com"); Csc20Student csc20Student = new Csc20Student("John Doe", 123, "123 Somewhere", "415-555-1212", "johndoe@somewhere.com",true,15); System.out.println(student + " "); System.out.println(csc20Student + " "); } }

Csus Student -studentName: String - studentlid: int -studentAddress: String -studentEmail: String studentPhone: String CsusStudent(name: String, id: String, address: String, email: String, phone: String + getName: String + setName (name String): void + getd (): int + setld (id: int):void + getAddress : String + setAddress (address: String) : void + getEmai String + setEmail (email: String): void + getPhone 0: String + setPhone(phone String): void +toString0: String IS-A Csc20 Student - preComputerMajor: boolean numberOfComputerClassUnit int Csc20Student(name: String, id: String, address: String, email: String, phone: String, precs: boolean, numunits: in +getPreComputerMajor boolean + setPreComputerMajor(value: boolean) void + getNumberofCsUnits0: int + setNumberofCsUnits(units: int): void +toStringo: String

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!