Question:

Java Arrays with class input?

by Guest31985  |  earlier

0 LIKES UnLike

I have written a class that outlines sets the Length and the Width and has a Method to calculate the area. My driver Program has to prompt the user to enter the how many rooms they have which initialises the size of an array in which I have a for loop to as the user to enter the Length and Width. This I can do but how to I get the array to hold each variable so I may output the value. I have tried something like

Room roomNo = new Room /* to create a new room class

and double myRoom[] /* to initialise the array

and for every count on the for loop myRoom = newRoom.getLength

But this brings up a incompatible data type error

Please Help!!!!

Cheers

 Tags:

   Report

1 ANSWERS


  1. This seems too simple but have you thought of

    Room myRoom[]

    to initialise the array as a room array?

    Now you do not have to worry about the Room variables.

    You now have an array of rooms.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.