+1 (315) 557-6473 

Create a Program to Implement Junit in Java Assignment Solution.


Instructions

Objective
Write a java assignment program to implement Junit.

Requirements and Specifications

program to implement Junit in java
program to implement Junit in java 1

Source Code

/**

* A person is someone who has a birth date and a name.

*

* @author Hp Envy

*/

public class Person {

/**

* Year of birth

*/

private int yob;

/**

* Given name

*/

private String firstName;

/**

* Surname

*/

private String lastName;

/**

* Original first name before update

*/

private String origFirstName;

/**

* Initialize a new person.

*

* @param yob Year of birth

* @param firstName Given name

* @param lastName Surname

*/

public Person(int yob, String firstName, String lastName) {

this.yob = yob;

this.firstName = firstName;

this.lastName = lastName;

}

/**

* Initialize a person.

*

* @param firstName Given name

* @param lastName surname

* @param yob Year of birth

*/

public Person(String firstName, String lastName, int yob) {

this.yob = yob;

this.firstName = firstName;

this.lastName = lastName;

}

/**

* Return the full name of the person

*

* @return Full name

*/

public String getName() {

return firstName + " " + lastName;

}

/**

* Initialize the first name of the person.

*

* @param newFirstName First name

*/

public void setFirstName(String newFirstName) {

origFirstName = this.firstName;

this.firstName = newFirstName;

}

/**

* Access to the original first name.

*

* @return Original first name before update

*/

public String getOrigFirstName() {

return origFirstName;

}

/**

* Access to the first name property.

*

* @return First name

*/

public String getFirstName() {

return firstName;

}

/**

* Access to the year of birth property.

*

* @return Year of birth

*/

public int getYearOfBirth() {

return yob;

}

/**

* Access to the last name property.

*

* @return Last name

*/

public String getLastName() {

return lastName;

}

/**

* Return a string representation of a person.

*

* @return Full name

*/

@Override

public String toString() {

return getName();

}

/**

* Test the person class through observing the output.

*

* @param args Unused arguments

*/

public static void main(String[] args) {

int a = 1;

int b = 5;

// create an object/instance out of class

// instantiate a class

person person1 = new Person(1989, "Tom", "Cheng");

Person person2 = new Person(2000, "Tom1", "Cheng1");

/*

System.out.println(person1.yob);

System.out.println(person2.yob);

person1.yob = 1920;

System.out.println(person1.yob);

*/

System.out.println(person1.getName());

person1.setFirstName("Jack");

System.out.println(person1.getName());

System.out.println(person1.getOrigFirstName());

}

}