Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create and run JunitTest cases for the following Java classes class Person { pro

ID: 3731329 • Letter: C

Question

Create and run JunitTest cases for the following Java classes

class Person {

protected String name;

protected String address;

protected String phoneNumber;

protected String email;

Person(String name) {

    this.name = name;

}

public String getName() {

    return name;

}

@Override

public String toString() {

    return "Person: " + name;

}

}

class Student extends Person {

public static int FRESHMAN = 1;

public static int SOPHOMORE = 2;

public static int JUNIOR = 3;

public static int SENIOR = 4;

protected int status;

Student(String name) {

    super(name);

}

@Override

public String toString() {

    return "Student: " + getName();

}

}

class Employee extends Person {

protected String office;

protected int salary;

protected java.util.Calendar dateHired;

Employee(String name) {

    super(name);

}

@Override

public String toString() {

    return "Employee: " + getName();

}

}

class Faculty extends Employee {

public static int LECTURER = 1;

public static int ASSISTANT_PROFESSOR = 2;

public static int ASSOCIATE_PROFESSOR = 3;

public static int PROFESSOR = 4;

protected String officeHours;

protected int rank;

Faculty(String name) {

    super(name);

}

@Override

public String toString() {

    return "Faculty: " + name;

}

}

class Staff extends Employee {

protected String title;

Staff(String name) {

    super(name);

}

@Override

public String toString() {

    return "Staff: " + getName();

}

}

Explanation / Answer

package mypackage;

import static org.junit.Assert.*;

import org.junit.Test;

public class PersonGetNameTest {

@Test

public void personGettest() {

Person person=new Person("Srikanth");

String name=person.getName();

assertEquals("Srikanth", name);

}

}

package mypackage;

import static org.junit.Assert.*;

import org.junit.Test;

public class PersonToStringTest {

@Test

public void test() {

Person person=new Person("Srikanth");

String name=person.toString();

assertEquals("Person: Srikanth", name);

}

}

package mypackage;

import static org.junit.Assert.*;

import org.junit.Test;

public class StudentToString {

@Test

public void test() {

Student student=new Student("Srikanth");

String name=student.toString();

assertEquals("Student: Srikanth", name);

}

}

package mypackage;

import static org.junit.Assert.*;

import org.junit.Test;

public class EmployeeToStringTest {

@Test

public void test() {

Employee employee=new Employee("Srikanth");

String name=employee.toString();

assertEquals("Employee: Srikanth", name);

}

}

package mypackage;

import static org.junit.Assert.*;

import org.junit.Test;

public class FacultyToStringTest {

@Test

public void test() {

Faculty faculty=new Faculty("Srikanth");

String name=faculty.toString();

assertEquals("Faculty: Srikanth", name);

}

}

package mypackage;

import static org.junit.Assert.*;

import org.junit.Test;

public class StaffToStringTestTest {

@Test

public void test() {

Staff staff=new Staff("Srikanth");

String name=staff.toString();

assertEquals("Staff: Srikanth", name);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote