在此代码的底部,我收到“无法访问的语句”错误。我尝试了一些事情,但无法弄清楚为什么会这样。错误在代码的底部(我已经用//评论了错误所在的位置)请帮助我指出正确的方向,我很难过!
/**
* Describes a certain model.
*
* @author (Joshua Baker)
* @version (1.0)
*/
public class Model
{
public static final int IN_PER_FOOT = 12;
public static final int BASE_RATE = 60;
public static final int TALL_INCHES = 67;
public static final double THIN_POUNDS = 140.0;
public static final int TALL_THIN_BONUS = 5;
public static final int TRAVEL_BONUS = 4;
public static final int SMOKER_DEDUCTION = 10;
private String firstName;
private String lastName;
private int heightInInches;
private double weightInPounds;
private boolean travel;
private boolean smokes;
private String newHeight;
private int perHourRate;
/**
* Default constructor
*/
public Model()
{
setFirstName ("");
setLastName ("");
setHeightInInches (0);
setWeightInPounds (0.0);
setTravel (false);
setSmokes (false);
}
/**
*
*/
public Model (String whatIsFirstName, String whatIsLastName, int whatIsHeight, double whatIsWeight,
boolean canTravel, boolean smoker)
{
setFirstName (whatIsFirstName);
setLastName (whatIsLastName);
setHeightInInches (whatIsHeight);
setWeightInPounds (whatIsWeight);
setTravel (canTravel);
setSmokes (smoker);
}
/**
*@return first name
*/
public String getFirstName()
{
return firstName;
}
/**
*@return last name
*/
public String getLastName()
{
return lastName;
}
/**
*@return height in inches
*/
public int getHeightInInches()
{
return heightInInches;
}
/**
*@return the converted height
*/
public String getNewHeight()
{
return newHeight;
}
/**
*@return weight in pounds
*/
public double getWeightInPounds()
{
return weightInPounds;
}
/**
*@return models pay per hour rate
*/
public int getPerHourRate()
{
return perHourRate;
}
/**
*@return travel
*/
public boolean getTravel()
{
return travel;
}
/**
*@return smokes
*/
public boolean getSmokes()
{
return smokes;
}
/**
* models first name
*/
public void setFirstName(String whatIsFirstName)
{
firstName = whatIsFirstName;
}
/**
* models last name
*/
public void setLastName(String whatIsLastName)
{
lastName = whatIsLastName;
}
/**
* models height in inches
*/
public void setHeightInInches(int whatIsHeight)
{
if (whatIsHeight >0){
heightInInches = whatIsHeight;
}
}
/**
* models weight in pounds
*/
public void setWeightInPounds(double whatIsWeight)
{
if (whatIsWeight >0){
weightInPounds = whatIsWeight;
}
}
/**
* can model travel
*/
public void setTravel(boolean canTravel)
{
travel = canTravel;
}
/**
* does model smoke
*/
public void setSmokes(boolean smoker)
{
smokes = smoker;
}
/**
* Converts to feet and inches
*/
public String convertheightToFeetInches()
{
int leftOver = (heightInInches %= IN_PER_FOOT);
int newHeight = (heightInInches % IN_PER_FOOT);
return newHeight + "Foot" + leftOver + "Inches";
}
/**
*
*/
public int calculatePayPerHour(){
if (heightInInches >= TALL_INCHES && (weightInPounds <= THIN_POUNDS)) {
perHourRate = BASE_RATE + TALL_THIN_BONUS;
return perHourRate;
}
else
{
perHourRate = BASE_RATE;
return perHourRate;
}
if (travel) { //unreachable statement
perHourRate = BASE_RATE + TRAVEL_BONUS;
return perHourRate;
}
else
{
perHourRate = BASE_RATE;
return perHourRate;
}
if (smokes) { //unreachable statement
perHourRate = BASE_RATE - SMOKER_DEDUCTION;
return perHourRate;
}
else {}
}
/**
* Displays details
*/
public void displayInfo()
{
System.out.print("Name : " + getFirstName() + " ");
System.out.println(getLastName());
System.out.println("Height : " + getNewHeight() + "inches");
System.out.println("Weight : " + getWeightInPounds() + "pounds");
System.out.print("Travel : " + getTravel() + " " );
System.out.print("Smokes : " + getSmokes() );
System.out.println("Hourly rate : " + getPerHourRate() );
}
}