Ok, now I realise this is only my second post and I'm sorry that its going to be a biggie, but this has me completely stumped.
To start with, this is for a university course, so I don't want you guys to give me the answer (IE code) but I would love some idea of where it is I am going wrong here. I'll post the code.
public class Triangle
{
/* instance variables */
int size; // the size of the triangle; an integer between 2 and 10 inclusive
String orientation; // either "up" or "down"
String startSize;
String startOrientation;
/**
* Constructor for objects of class Triangle.
*/
public Triangle()
{
// super();
// M255 TMA 02 Q1 (i)
// size = 5;
// orientation = "down";
this.inputSize() = startSize;
this.inputOrientation() = startOrientation();
}
is the constructor I am attempting to create.
public void inputSize(String uSize)
{
uSize = OUDialog.request("Please enter an integer between 2 and 10 inclusive.");
if (this.isValidSize(uSize))
{
size = Integer.parseInt(uSize);
}
else
{
OUDialog.alert(uSize + " is outside the parameters of the request.");
}
}
and
public void inputOrientation(String uOrientation)
{
uOrientation = OUDialog.request("Please enter the orientation of your triangle, 'up' or 'down'.");
if (this.isValidOrientation(uOrientation))
{
orientation = uOrientation;
}
else
{
OUDialog.alert(uOrientation + " is neither the word 'up' or 'down'.");
}
}
are the two methods I am trying to call when the class is initialised.
The idea is (in the modified BlueJ workspace) when
Triangle t;
t = new Triangle();
is executed, a dialog box comes up asking for the size and orientation of the desired triangle. If neither of them fall within the requested parameters, the user is alerted and told to try again.
I'm happy with the two loops inputSize() and inputOrientation() but when I try to compile with the new constructor (posted waaay above) I get an error which says
inputSize(java.lang.String) in Triangle cannot be applied to ()
I don't know what I've done wrong here, can anyone please pont me in the right direction?
cheers,
Alan