I am working on a lab for school where we fix a client that takes patient information. We do this by going over the source, and the test client, and correcting errors until we pass all our tests. My code compiles, and all my tests pass, but when I submit my assignment to a software called "WebCat" I keep getting this error.. ClientTest.java:50: cannot find symbol
What is causing this error?
I have been working on this for 3 days now, and I can not figure this out.
/**
* Maintains information on an insurance client.
*
* @author Doyt Perry/<Jeremy E. Forrest>
* @version Fall 2015
*/
public class Client
{
// instance variables
private String lastName;
private String firstName;
private int age;
private int height;
private double weight;
/**
* First constructor for objects of class Client.
*/
public Client()
{
// initialize all instance variables to placeholder values
this.lastName = "last name";
this.firstName = "first name";
this.age = 0;
this.height = 1;
this.weight = 1.0;
}
/**
* Second constructor for objects of class Client.
*
*
* Create a client object using explicit parameters to specify
* values for corresponding instance fields.
*
* @param inLastName last Name of client
* @param inFirstName first Name of client
* @param inAge age of client
* @param inHeight height of client
* @param inWeight weight of client
*/
public Client(String inLastName, String inFirstName, int inAge,
int inHeight, double inWeight)
{
// initialize instance variables
// using values passed in as parameters
this.lastName = inLastName;
this.firstName = inFirstName;
this.age = inAge;
this.height = inHeight;
this.weight = inWeight;
}
/**
* Update the last name of the client.
*
* @param inLastName last name of the client.
*/
public void setLastName(String inLastName)
{
// Set the last name instance variable to parameter
this.lastName = inLastName;
}
/**
* Return the last name of the client.
*
* @return String last name.
*/
public String getLastName()
{
// return the value of the last name instance variable
return this.lastName;
}
/**
* Update the first name.
*
* @param inFirstName first name of the client.
*/
public void setFirstName(String inFirstName)
{
this.firstName = inFirstName;
}
/**
* Return the first name of the client.
*
* @return String first name.
*/
public String getFirstName()
{
return this.firstName;
}
/**
* Update the age of the client.
*
* @param inAge age of the client.
*/
public void setAge(int inAge)
{
// Set the age instance variable to the parameter
this.age = inAge;
}
/**
* Return the age of the client.
*
* @return int first name.
*/
public int getAge()
{
// return the value of the first age instance variable.
return this.age;
}
/**
* Update the height of the client.
*
* @param inHeight height of the client.
*/
public void setHeight(int inHeight)
{
// Set the height instance variable to the parameter
this.height = inHeight;
}
/**
* Return the height of the client.
*
* @return int height of client.
*/
public int getHeight()
{
// return the value of the height instance variable.
return this.height;
}
/**
* Update the weight of the client.
*
* @param inWeight weight of the client.
*/
public void setWeight(double inWeight)
{
this.weight = inWeight;
}
/**
* Return the weight of the client.
*
* @return double weight of client.
*/
public double getWeight()
{
return this.weight;
}
/**
* Calculate the BMI of the client.
*
* @return double BMI of client.
*/
public double calcBMI()
{
// return the result of calculating the BMI.
return (703 * this.weight) / (this.height * this.height);
}
/**
* Display the client information.
*
* @return String formatted client informatin.
*
* <pre>
* The label should be printed in the format:
*
* last name, first name
* Age: 99
* BMI: 99.999
* </pre>
*/
public String toString()
{
// initialize the variable that will hold the output string
String output = "";
// put the name in lastname, firstname format
output = output + this.lastName + "," + " " + this.firstName + "\n";
// include the client age
output = output + "Age " + this.age + "\n";
// include the email address
output = output + "BMI " + this.calcBMI() + "\n";
// return the output string
return output;
}
}
import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* The test class ClientTest tests the Client class.
*
* @author Doyt Perry/<add your name here>.
* @version Fall 2015
*/
public class ClientTest
{
/**
* Default constructor for test class ClientTest.
*/
public ClientTest()
{
// not used in this Lab
}
/**
* Sets up the test fixture.
*
* Called before every test case method.
*/
@Before
public void setUp()
{
// not used in this Lab
}
/**
* Tears down the test fixture.
*
* Called after every test case method.
*/
@After
public void tearDown()
{
// not used in this Lab
}
/**
* Test Client constructor #1 (no parameters).
*/
@Test
public void testConstructor1()
{
// Create a client object using the constructor with no parameters.
Client tstClient = new Client();
// Verify instance variables have been set to placeholder values
assertEquals("last name", tstClient.getLastName());
assertEquals("first name", tstClient.getFirstName());
assertEquals(0, tstClient.getAge());
assertEquals(1, tstClient.getHeight());
assertEquals(1.0, tstClient.getWeight(), .001);
}
/**
* Test Client constructor #2 (5 parameters).
*/
@Test
public void testConstructor2()
{
// Create a client object using the constructor with 5 parameters.
Client tstClient = new Client("Smith", "Carl", 44, 70, 200);
// Verify instance variables have been set to the passed in values
assertEquals("Smith", tstClient.getLastName());
assertEquals("Carl", tstClient.getFirstName());
assertEquals(44, tstClient.getAge());
assertEquals(70, tstClient.getHeight());
assertEquals(200, tstClient.getWeight(), .001);
}
/**
* Test setLastName method.
*/
@Test
public void testSetLastName()
{
// Create a client object using the constructor with 5 parameters.
Client tstClient = new Client("Smith", "Carl", 44, 70, 200);
// set the last name to a new value
tstClient.setLastName("Smithsonian");
// Verify last name has been set to new value
assertEquals("Smithsonian", tstClient.getLastName());
}
/**
* Test set setFirstName method.
*/
@Test
public void testSetFirstName()
{
// Create a client object using the constructor with 5 parameters.
Client tstClient = new Client("Smith", "Carl", 44, 70, 200);
// set the first name to a new value
tstClient.setFirstName("Robert");
// Verify first name has been set to new value
assertEquals("Robert", tstClient.getFirstName());
}
/**
* Test setAge method.
*/
@Test
public void testSetAge()
{
// Create a client object using the constructor with 5 parameters.
Client tstClient = new Client("Smith", "Carl", 44, 70, 200);
// set age to a new value
tstClient.setAge(39);
// REMOVE this comment and fix the test below
// Verify age has been set to new value
assertEquals(39, tstClient.getAge());
}
/**
* Test setHeight method.
*/
@Test
public void testSetHeight()
{
// Create a client object using the constructor with 5 parameters.
Client tstClient = new Client("Smith", "Carl", 44, 70, 200);
// set height to a new value
tstClient.setHeight(66);
// Verify height has been set to new value
assertEquals(66, tstClient.getHeight());
}
/**
* Test setWeight method.
*/
@Test
public void testSetWeight()
{
// Create a client object using the constructor with 5 parameters.
Client tstClient = new Client("Smith", "Carl", 44, 70, 200);
// set weight to a new value
tstClient.setWeight(180);
// Verify weight has been set to new value
assertEquals(180, tstClient.getWeight(), .001);
// REPLACE these comments with code that sets the weight to
// a different value & then verifies the updating has been done
}
/**
* Test calcBMI method.
*
* NOTE TO 111 STUDENTS: This test method IS correct!!!
* DO NOT MODIFY IT
*
*/
@Test
public void testCalcBMI()
{
// Create a client object using the constructor with 5 parameters.
Client tstClient = new Client("Smith", "Carl", 44, 70, 200);
// Verify BMI has been correctly calculated (with delta of.01)
assertEquals(28.69, tstClient.calcBMI(), .1);
}
/**
* Test the toString method.
*
* NOTE TO 111 STUDENTS: This test method IS correct!!!
* DO NOT MODIFY IT
*
*/
@Test
public void testToString()
{
// Create a client object using the constructor with no parameters.
Client tstClient = new Client();
// call the toString() method to retrieve the output
String tstOutput = tstClient.toString();
// verify client name is in correct output format
assertTrue(tstOutput.contains("last name, first name"));
// verify client age is included in output stream
assertTrue(tstOutput.contains("0"));
// verify BMI is correctly calculated
assertTrue(tstOutput.contains("0"));
// Create a client object using the constructor with 5 parameters.
tstClient = new Client("Smith", "Carl", 44, 70, 200);
// call the toString() method to retrieve the output
tstOutput = tstClient.toString();
// verify client name is in correct output format
assertTrue(tstOutput.contains("Smith, Carl"));
// verify client age is included in output stream
assertTrue(tstOutput.contains("44"));
// verify client BM is correctly calculated
assertTrue(tstOutput.contains("28."));
}
}
Aucun commentaire:
Enregistrer un commentaire