Binary
Member
For pure randomness, I have created a java class in less a few minutes. Save it under Calcuator.java before compiling. I'll edit this thread to improve this code. If you have questions or comments, please feel free to post here.
Code:
public class Calculator
{
private int a, b, c;
public Calculator()
{
this(0, 0);
}
public Calculator(int a, int b)
{
this.a = a;
this.b = b;
}
public int geta()
{
return a;
}
public int getb()
{
return b;
}
public int seta(int a)
{
this.a = a;
return a;
}
public int setb(int b)
{
this.b = b;
return b;
}
public int total(int a, int b)
{
c = a + b;
return c;
}
public String toString()
{
String results = a + " + " + b + " = " + total(a,b);
return results;
}
public static void main(String[] args)
{
Calculator calc = new Calculator(2,3);
calc.seta(5);
calc.setb(2);
System.out.println(calc.toString());
}
}