Hi there,

Any recommendation on Java books for starter?
Just received an assignment on doing a cinema booking system..
Normally how long will it takes to complete this program?
The lecturer gave us 2 weeks to complete this assignment, is it reasonable?
Thanks for your kind reply.
Cheers, happy new year^^
Best Regards,
Roland

Recommended Answers

All 9 Replies

Java For Dummies is decent.

Two weeks is a reasonable amount of time if that's all you have :)

If you have good technique, it might take you a couple of days.
If you need to research every command, it might take the full two weeks.
Start immediately.

Hi thines01,

Thanks for your prompt reply^^...
Actually i still figuring out how to do the assignment.
For example the array as below:

1 A B C D E
2 A B C D E

If seats 1 A already taken, how to mark the specific seat as 'X'?
Looking forward to your reply.

Best Regards,
Roland

if it's a String, you can use the indexOf method to find the location of the substring you need to replace, and replace that char with X.
there are various ways to do this, normally, all you need to complete this task is in your syllabus in the chapter(s) you've already dealt with during class.

What you're making won't be as simple as the code below, but you can handle it with a 2-dimensional array.

You will need to make a menu system asking the user to reserve a seat and then
have the system mark it as reserved after it checks to see if it's still available.

Here is something to get you thinking:

public class Airline
{
   public static void main(String[] args)
   {
      char[][] arr_chrSeats =
      {
         {'A', 'B', 'C', 'D', 'E'},//0
         {'A', 'B', 'C', 'D', 'E'},//1
         {'A', 'B', 'C', 'D', 'E'},//2
         {'A', 'B', 'C', 'D', 'E'},//3
         {'A', 'B', 'C', 'D', 'E'},//4
      };


      for (int i=0; i<arr_chrSeats.length; i++)
      {
         System.out.print(i);
         for(int j=0; j<arr_chrSeats[i].length; j++)
         {
            System.out.print(arr_chrSeats[i][j]);
         }

         System.out.println();
      }

      System.out.println("\npretend seat 1A is taken\n");
      arr_chrSeats[0][0]='X';

      for (int i=0; i<arr_chrSeats.length; i++)
      {
         System.out.print(i);
         for(int j=0; j<arr_chrSeats[i].length; j++)
         {
            System.out.print(arr_chrSeats[i][j]);
         }

         System.out.println();
      }
   }
}

Hi thines01,

a question to ask..
arr_chrSeats.length --> what length does it refers to?The length of the array which is [3]?

you mean arr_chrSeats.length
which means: the length (number of elements) that is stored in the arr_chrSeats
this length depends on each iteration over the original array.
well, in this case, not really, since all arrays have the same length, being:
5

stultuske is correct.
It tells the length of (or number of elements in) each row in the array.
Since that is a known (hard-coded) number, you can simply use the number 5.
If there is a possibility you will not know the number (of seats or rows), you can use the length property to keep from going outside the bounds.

Hi guys,

thanks for the kind reply..
appreciate it much..will post if I have any doubts on the assignment^^..
u guys are fantastics!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.