hi i need help creating a program using arrays. this is what is assigned and i cant figure much of it out ! please help!

The single field (instance variable) for this class is a array of type char named seats[] with 10 elements. The first five elements (0 to 4) in the array store information about seats in First Class; the last five elements (5 to 9) are for Coach. A value of 'O' for any element means that the seat is unassigned; a value of 'X' for a seat element means that it has been reserved.

The seats[] array field should be declared with no initial values assigned and instantiated in the constructor method. In the constructor then use a loop (of any type, although if you choose a loop structure using the array's index, use the array's length property as the terminating value for the loop) that assigns the character value 'O' to all ten elements (meaning that the seats are unassigned). At the conclusion of the constructor, call the displaySeats() method (see below) to show the plane's reservation status.

i know how to create the array object for seats but i got stuck at the constructor..can anybody help me!

Do you know what constructor is? Also, I think you need to break the requirement down into step by step.

1)declare an array of type char named seats with no initial values
2)instantiated the array in the constructor method
3)use a loop using the array's length property to assign the character value 'O' to all elements
4)call the displaySeats()

If you look at the steps above after broken down the requirement, only #1 is not inside the class constructor. Is that where you are stuck right now? If so, you should show us how you accomplish #1 and stuck in #2, #3, or #4.

This article has been dead for over six months. Start a new discussion instead.