I need to build a program - hotel, which has from 1 to XXX rooms.
It is ok, when I have only the:
private static int[] array_of_rooms;
<... CLASS CONSTRUCTOR ...>
array_of_rooms = new int[size]; // Size is defined size, of rooms in the hotel.
// Fill default room status
for(int i = 0; i < size; i++)
{
array_of_rooms[i] = 0;
}
<... END OF CLASS CONSTRUCTOR ...>
But I'm search sth like I had I C++.
struct type_room
{
int id;
int status;
String start_date;
String end_date;
};
I tried sth like this in Java:
public class room {
public int status;
public String start_date;
public String end_date;
}
And then define the new type:
private static room[] array_of_rooms; // "room" is my new type
<... CLASS CONSTRUCTOR ...>
// All ok
array_of_rooms = new room[size];
// Fill room's array
for(int i = 0; i < size; i++)
{
array_of_rooms.room_id[i] = i+1;
array_of_rooms.room_status[i] = 0;
array_of_rooms.start_date[i] = "2009-09-19";
array_of_rooms.start_date[i] = "2009-09-29";
}
<... END OF CLASS CONSTRUCTOR ...>
But elements filling don't work. How I can fill & access the elements of array of my own type, which is sth like struct in c++.
Thanks.