Rik Ny

Greenhorn
+ Follow
since Oct 13, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Rik Ny

How do I place a pic or logo of my own on a JPanel??
21 years ago
If you have created an array in one class and you wish to use it in another class, how do you go about doing it?? Cheers,Rik
22 years ago
I am having trouble getting the code below to do what i want. I need the code to randomly generate a number between 0 and 45, if the number is between 0 and 45 it will place it in the array. But how do I make it generate another number if the one before it is not between 0 and 45???
Cheers,Rik
int Game1 [] = new int [1000];
for(int counter = 0; counter < 1000 ; counter ++)
{
int num = (int)(Math.random()*100);
if((num > 0) && (num <= 45))
{
Game1[counter] = num;
}
}
22 years ago
D:\My Java\GenerateRandomInt.java:41: cannot resolve symbol
symbol : method intValue (int)
location: class java.lang.Integer
System.out.println(firstNumber.intValue(counter));
^
1 error
Tool completed with exit code 1
What the ......???
Cheers, Rik
22 years ago
I have created a Vector which stores random numbers, but I am having trouble retrieving them. How do I retrieve each individual element and print it to a screen??
P.S This vector stores numbers (int)
Cheers,Rik
22 years ago
Thanks, but here is my try catch block. Am I using the write Exception???
protected void UserResponse(BufferedReader responseReader)
{
try
{
response =Integer.parseInt(responseReader.readLine());
}
catch(Exception ex)
{
System.out.println("ERROR:- " + ex);
}
}
22 years ago
Hello there, I have written a program that gets input from the user and then prints it to a file. However because I am using BufferedReader i have had to use a try and catch block. For the input i have placed a catch block which catches any invalid values. However when the program runs, and the user enters a invalid value it shows the exception which I want. But is there any way that I can make the program continue once a exception has been caught??? I.e. once my program catches an exception it terminates the entire program. Cheers, Rik
22 years ago
Hey christopher, if you wouldn't mind could I have some more details on how to implement your theory. Cheers.
22 years ago
So there's a way. But the question was how??
22 years ago
How do i pass the variables "mname","mtype", "mID" ect out of this class and into another class
where it is required. I require them in an abstract class where they will be printed to a file.
I need a solution ASAP. Cheers, here is my problem.....
class MJInput
{
public void InputHere()
{
BufferedReader userinput = new BufferedReader(new InputStreamReader(System.in));
try
{
System.out.println("------------Military Jet Information------------\n");
System.out.println("Welcome, please answer the following questions:-\n");
System.out.print("Aircraft Name:- ");
String mname = userinput.readLine();
System.out.print("Aircraft Type:- ");
String mtype = userinput.readLine();
System.out.print("Aircraft ID Number:- ");
int mID = Integer.parseInt(userinput.readLine());
System.out.print("Aircraft Capacity:- ");
int mcapacity = Integer.parseInt(userinput.readLine());
System.out.println();
userinput.close();
}
catch(IOException ioe)
{
System.out.println("Error:- " + ioe);
}
}
}
22 years ago
How do i pass the variables "mname","mtype", "mID" ect out of this class and into another class
where it is required. I require them in an abstract class where they will be printed to a file.
I need a solution ASAP. Cheers, here is my problem.....
class MJInput
{
public void InputHere()
{
BufferedReader userinput = new BufferedReader(new InputStreamReader(System.in));
try
{
System.out.println("------------Military Jet Information------------\n");
System.out.println("Welcome, please answer the following questions:-\n");
System.out.print("Aircraft Name:- ");
String mname = userinput.readLine();
System.out.print("Aircraft Type:- ");
String mtype = userinput.readLine();
System.out.print("Aircraft ID Number:- ");
int mID = Integer.parseInt(userinput.readLine());
System.out.print("Aircraft Capacity:- ");
int mcapacity = Integer.parseInt(userinput.readLine());
System.out.println();
userinput.close();
}
catch(IOException ioe)
{
System.out.println("Error:- " + ioe);
}
}
}
22 years ago
I would like to know how to convert a BufferedReader varaible into an int for my switch statement?? Here's what i have so far...
public void sendto(BufferedReader response)
{
try
{
int option = response.read();
switch(option)
22 years ago
If I have an abstract class with two children, then how do I create an object of each of the children from the driver??
Cheers,
22 years ago