Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

X 1 2 6 8 : Write JUnit test case for accessor method Use this partial definition of a Student class to solve this exercise.

X1268: Write JUnit test case for accessor method
Use this partial definition of a Student class to solve this exercise.
public class student
q
II create a new student with name and birth year
public Student(String name, int birthYear)
// returns the name of the student
String getName()
I/ stores the name of the student
void setName(String name)
// sets the birth year of the student
boolean setBirthYear(int year) I
// returns the birth year of the student
int getBirthYear()
// returns the student's age by subtracting today
// age from the birth year
}
int getAge()
And consider these lines of code that create three instances of Student objects.
1 Student futureCEO = new Student ("B Gates", 1955);
Student firstCoder = new Student("A Lovelce",1815);
Student hiddenEngineer = new Student ("K Johnson", 1918);
Write a JUnit test case that checks that (i.e., asserts) the futureCE0 was born in 1955. In other words, it asserts that birth yea access the futureCEO instance, and call the getBirthYear().
Your Answer:
Feedback
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Design And SQL For DB2

Authors: James Cooper

1st Edition

1583473572, 978-1583473573

Students also viewed these Databases questions

Question

What happened to the Phillips curve in the late 1990s?

Answered: 1 week ago