Search:

Type: Posts; User: rph

Search: Search took 0.08 seconds.

  1. 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. 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. Replies
    7
    Views
    4,976

    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. Replies
    7
    Views
    4,976

    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. Replies
    7
    Views
    4,976

    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. Replies
    7
    Views
    4,976

    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. 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. 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. 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