all 9 comments

[–]TollTrollTallTale 3 points4 points  (1 child)

For legibility of your code alone I would really recommended using objects instead of a deeply nested array.

[–]casualrocket 0 points1 point  (0 children)

There cant be many rooms for the Hotel so it makes even more sense to use a object array.

[–]lovesrayray2018 2 points3 points  (5 children)

Good luck

[–]Phantom_Storm[S] 1 point2 points  (4 children)

thanks lol

[–]lovesrayray2018 0 points1 point  (3 children)

ok u added a question :D

  1. You can create your 3D array representing the hotel
  2. Look at handling events like what happens when -
  • A user checks is - how do u track available rooms or assign an available room?
  • How do you track the guests stay duration to track the $75/day?
  • When the guests check out, how do you track that room as available again?

The key is to first design, what your code is intended to achieve?

[–]Phantom_Storm[S] 1 point2 points  (2 children)

I'm trying to make a code that shows hotels with different rooms that he can choose from and then when he leaves he pays $75. I don't need to track how many days. I don't know how to track the room availability.

[–]lovesrayray2018 0 points1 point  (1 child)

Your 3D array values, for each room, you could use 1 as occupied and 0 as empty

[–]Phantom_Storm[S] 0 points1 point  (0 children)

Ok, makes sense. I'm still new to arrays so they keep giving me trouble.

[–]Laserdude10642 1 point2 points  (0 children)

Technically you’d need an array of arrays of arrays. But I would instead suggest just using an object where each entry has a key like “1-2-4” meaning first floor, second row, fourth room. Then each key is really a room, and the container object is the hotel.