I need to create a TestCase to test displayAddress() and displayAddressLabel().
ID: 639268 • Letter: I
Question
I need to create a TestCase to test displayAddress() and displayAddressLabel(). displayAddress is used to display the general address with no name and displayAddressLabel() is used to display the name with the addres. How do I write a test case to do this? It is done in java. Also, I have attached my Customer Class that is used for the test case.
package core;
public class Customer
{
String name;
String streetAddress;
String city;
String state;
String zip;
int age;
public Customer(String n,String s,String c,String st,String z, int a)
{
name = n;
streetAddress = s;
city=c;
state=st;
zip=z;
age = a;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getStreetAddress()
{
return streetAddress;
}
public void setStreetAddress(String streetAddress)
{
this.streetAddress = streetAddress;
}
public String getCity()
{
return city;
}
public void setCity(String city)
{
this.city = city;
}
public String getState()
{
return state;
}
public void setState(String state)
{
this.state = state;
}
public String getZip()
{
return zip;
}
public void setZip(String zip)
{
this.zip = zip;
}
public int getAge()
{
return age;
}
public void setAge(int age)
{
this.age = age;
}
public String displayAddress()
{
return getStreetAddress() + " " + getCity() + ", " + getState() + " " + getZip();
}
public String displayAddressLabel()
{
return getName() +" " + getStreetAddress() + " " + getCity() + ", " + getState() + " " + getZip();
}
}
Explanation / Answer
public class TestCustomer {
public static void main(String[] args) {
Customer c = new Customer("Einstein","Wall Street","NY","New York","10025",23);
System.out.println("Testing dislpayAddress Function: ADDRESS-->");
c.displayAddress();
System.out.println(" Testing dislpayAddressLabel Function: ADDRESS-->");
c.displayAddressLabel();
}
}
------------------------------------------------------------------------------------
OUTPUT
Testing dislpayAddress Function:
ADDRESS-->
Wall Street,
New York,
NY,
10025
Testing dislpayAddressLabel Function:
ADDRESS-->
Einstein,
Wall Street,
New York,
NY,
10025
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.