Skip to content

Instantly share code, notes, and snippets.

@benfb
Created October 7, 2012 18:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benfb/3849120 to your computer and use it in GitHub Desktop.
Save benfb/3849120 to your computer and use it in GitHub Desktop.
inOrder
public class InOrder //creates the InOrder class
{
private int numOne; //creates the instance variable numOne
private int numTwo; //creates the instance variable numTwo
private int numThree; //creates the instance variable numThree
boolean b = false; //creates the boolean value b (not instance)
public InOrder() //default constructor
{ //assigns default values to instance variables
numOne = 0;
numTwo = 0;
numThree = 0;
}
public InOrder(int n1, int n2, int n3) //initialization constructor
{ //assigns the arguments passed (x,y,z in the Runner) to instance variables
numOne = n1;
numTwo = n2;
numThree = n3;
}
//modifier methods for each instance variable
public void setNumOne(int n1)
{
numOne = n1;
}
public void setNumTwo(int n2)
{
numTwo = n2;
}
public void setNumThree(int n3)
{
numThree = n3;
}
//accessor methods for each instance variable
public int getNumOne()
{
return numOne;
}
public int getNumTwo()
{
return numTwo;
}
public int getNumThree()
{
return numThree;
}
// create method to determine if the numbers are in order
public boolean xyz()
{
if(numOne <= numTwo && numTwo <= numThree){//if 1 < 2 and 2 < 3, b = true
b = true;
}
return b; //return the boolean b
}
public String toString() //the toString method (not used)
{
return "" + numOne + " " + numTwo + " " + numThree + " are in order.";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment