# Search:

Type: Posts; User: rph

1. ## Thread: how to use nextInt() to generate random integers?

by rph
Replies
6
Views
2,859

### Re: how to use nextInt() to generate random integers?

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...
2. ## Thread: how to use nextInt() to generate random integers?

by rph
Replies
6
Views
2,859

### how to use nextInt() to generate random integers?

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...
3. ## Thread: How to convert from type double to type int?

by rph
Replies
7
Views
3,527

### Re: How to convert from type double to type int?

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 :)
4. ## Thread: How to convert from type double to type int?

by rph
Replies
7
Views
3,527

### Re: How to convert from type double to type int?

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...
5. ## Thread: How to convert from type double to type int?

by rph
Replies
7
Views
3,527

### Re: How to convert from type double to type int?

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...
6. ## Thread: How to convert from type double to type int?

by rph
Replies
7
Views
3,527

### How to convert from type double to type int?

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...
7. ## Thread: Inheritance in BlueJ, parent class has two parameters but child class has one...

by rph
Replies
7
Views
2,389

### Re: Inheritance in BlueJ, parent class has two parameters but child class has one...

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 :)
8. ## Thread: Inheritance in BlueJ, parent class has two parameters but child class has one...

by rph
Replies
7
Views
2,389

### Re: Inheritance in BlueJ, parent class has two parameters but child class has one...

Yeah sure :)

(Superclass)
public abstract class Shapes
{
abstract void changeSize(int newHeight, int newWidth);
}

(Sub-class 1)
public class Triangle extends Shapes
9. ## Thread: Inheritance in BlueJ, parent class has two parameters but child class has one...

by rph
Replies
7
Views
2,389

### Inheritance in BlueJ, parent class has two parameters but child class has one...

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...
Results 1 to 9 of 9