×
Samples Blogs Make Payment About Us Reviews 4.9/5 Order Now

Create a Program to Implement Junit in Java Assignment Solution

June 13, 2024
Dr. Hannah Lynch
Dr. Hannah
🇬🇧 United Kingdom
Java
Dr. Hannah, a distinguished Ph.D. holder from the University of York, brings over a decade of expertise to our service. With an impressive track record of completing 1100+ Java assignments, Dr. Hannah's profound knowledge and extensive experience ensure exemplary solutions tailored to meet your specific requirements.
Key Topics
  • Instructions
  • Requirements and Specifications
Tip of the day
Use Python libraries effectively by importing only what you need. For example, if you're working with data, using libraries like pandas and numpy can save time and simplify complex tasks like data manipulation and analysis.
News
In 2024, the Biden-Harris Administration has expanded high-dosage tutoring and extended learning programs to boost academic achievement, helping programming students and others recover from pandemic-related setbacks. These initiatives are funded by federal resources aimed at improving math and literacy skills​

Instructions

Objective

Write a java assignment program to implement Junit.

Requirements and Specifications

program-to-implement-Junit-in-java (1)
program-to-implement-Junit-in-java 2 (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()); } }

Similar Samples

Explore our wide range of programming assignment samples to see the quality and expertise we bring to every project. Each sample showcases our proficiency in various programming languages and complex problem-solving skills, providing a glimpse into the exceptional work you can expect from us.