Drawing Triangle
Having Trouble below.....where the astericks are.....any help would be great
private int side1;
private int side2;
private int side3;
private boolean firstTime = true;
public DrawingJPanel( String name)
{
super();
setBackground( Color.white );
setBorder( BorderFactory.createTitledBorder( name ) );
}
public void setSides( int s1, int s2, int s3 )
{
****************
I have to insert code to set the values of the sides.
Ensure that the attribute side3 is not
smaller than either side1 or side 2.
****************
}
> Having Trouble below.....where the astericks
> are.....any help would be great
>
>
>private int side1;
>private int side2;
>private int side3;
>private boolean firstTime = true;
>
>public DrawingJPanel( String name)
>{
> super();
> setBackground( Color.white );
> setBorder( BorderFactory.createTitledBorder(
> edBorder( name ) );
>}
>
> public void setSides( int s1, int s2, int s3
> int s3 )
>{
>****************
> I have to insert code to set the values of the
> of the sides.
>
>Ensure that the attribute side3 is not
>smaller than either side1 or side 2.
>****************
>}
So all you want is to ensure that side3 "is not smaller" that s2 or s1:
public void setSides( int s1, int s2, int s3)
{
if(s3 < s1){
throw new IllegalArgumentException("Side s3 is greater than or equal to s1!");
}
if(s3 < s2){
throw new IllegalArgumentException("Side s3 is greater than or equal to s2!");
}
// now do whatever you think you need to do.
}
nbloma at 2007-7-13 19:08:23 >
