I am just starting
java and would appreciate help!
Is this right and how can I
test it?
class Berth //class name
{
//declare the variables
private
String berthId;
private int berthWidth;
private int berthLength;
//Constructor
Berth(String Bi,int Bw,int Bl)
{
setberthId(Bi);
setberthWidth(Bw);
setberthLength(Bl);
}
// ===================================
//methods
public void setberthId (String Bi)/*start the methods to set the variables
set the berth ID*/
{
berthId=Bi;
}
public void setberthWidth (int Bw)//set the berth width
{
berthWidth=Bw;
}
public void setberthLength (int Bl)//set the berth length
{
berthLength=Bl;
}
//=======================================
public String getberthId() /*start the methods to return the variables
get the berth ID*/
{
return berthId;
}
public int getberthWidth() //get the berth width//
{
return berthWidth;
}
public int getberthLength() //get the berth length//
{
return berthLength;
}
// ===================================
public void display () // method to display the information
{
System.out.println("Berth ID : " + berthId);
System.out.println("Berth Width : " + berthWidth);
System.out.println("Berth Length : " + berthLength);
}
//end methods
}//end class