Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 29th, 2004, 7:31 PM   #1
JawaKing00
Newbie
 
Join Date: Sep 2004
Posts: 29
Rep Power: 0 JawaKing00 is on a distinguished road
Hello,

For a class I need to create an Airport Traffic Control Program.

The airport needs to have a number of runways that is determined at runtime.

In order to keep track of the runways I want to create an array of these runways. I have a runway class declared. How can I create an array of these runway objects in a different class?

It has been way too long since I've programmed in Java.

Could anyone help?

Thank you.
JawaKing00 is offline   Reply With Quote
Old Sep 29th, 2004, 8:23 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
Runway runway[] = new Runway[5]; //just using 5 as an example

for(int i = 0; i<runway.length; i++)
{
   runway = new Runway();
}
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Sep 29th, 2004, 8:43 PM   #3
JawaKing00
Newbie
 
Join Date: Sep 2004
Posts: 29
Rep Power: 0 JawaKing00 is on a distinguished road
Thanks.

Now I have another problem though...

Later in my Airport class I have a method getNumRunways where I'm trying to return the length of the runway array using return runway.length

The error I get when I try this is:
C:\Documents and Settings\Mindwalker1\My Documents\CS 161\Airport\Airport.java:71: cannot find symbol
symbol : variable runway
location: class Airport
return runway.length;
^
1 error

Thanks
JawaKing00 is offline   Reply With Quote
Old Sep 29th, 2004, 8:46 PM   #4
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
I have to go eat. Could you please post the code, and I'll come back and take a look.
__________________
&quot;Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children.&quot; - Dwight D. Eisenhower
Mjordan2nd is offline   Reply With Quote
Old Sep 29th, 2004, 9:03 PM   #5
JawaKing00
Newbie
 
Join Date: Sep 2004
Posts: 29
Rep Power: 0 JawaKing00 is on a distinguished road
Never mind, I solved it.

I had forgotten to declare the array outside of the method.

Solved now.
JawaKing00 is offline   Reply With Quote
Old Sep 30th, 2004, 12:28 AM   #6
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,472
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Bummer... I missed something that half-way sounded interesting.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:28 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC