Figured it out now, all i had to do was write:
static Random randGen = new Random();
int randomAng = randGen.nextInt(70) + 20;
in the public class and make sure I put:
import...
Type: Posts; User: rph
Figured it out now, all i had to do was write:
static Random randGen = new Random();
int randomAng = randGen.nextInt(70) + 20;
in the public class and make sure I put:
import...
So basically for my assignment, I need to generate a random integer number between 20 and 90. My textbook leaves a lot to be desired in the explanation of using nextInt(). I want to assign the random...
Never mind I've figured it out myself, I just had to move
int shortnumb2 = (int) shortnumb;
int length2 = (int) length;
into the public void paint class.
Thanks for all your help :)
Yeah that's what the problem was, I hadn't declared length2 as a class variable, thanks :)
However now I have the problem that the conversion from double to int makes the int value 0, any ideas why...
Ok I think I got that, but BlueJ is saying that I'm having an error still.
import java.awt.*;
import javax.swing.*;
public class goldenrect extends JApplet
{
double length;
public void...
I need to convert the result of a calculation from type double to type int, what's the best way of going about this?
I need to do this because I need the results of the calculation to be the length...
Thank you for the help, got the assignment done thanks to you, and good to see you're from Faversham dlorde, as I'm only in Whitstable :)
Yeah sure :)
(Superclass)
public abstract class Shapes
{
abstract void changeSize(int newHeight, int newWidth);
}
(Sub-class 1)
public class Triangle extends Shapes
I've been given an assignment that involves inheritance on BlueJ.
The superclass/ parent class has the following line of code:
"
abstract void changeSize(int newHeight, int newWidth);
"
The...