Results 1 to 6 of 6
  1. #1
    doran_lum is offline Member
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default Better Documentation for this codes

    I feel i can put in better documentation for this codes. Could anyone be able to assist what could be missing ?

    Java Code:
    import java.util.ArrayList; //Import Array List
    import java.util.Scanner; //Import scanner
     
    //2 diemension Array
        public class Project {
            final int rows = 7, cols = 4;
            char[][] seats = new char[rows][cols];
            ArrayList<String> reservedSeats = new ArrayList<String>();
     
            public static void main(String[] args) {
                Project q = new Project();
                q.buildSeats();
                q.printSeats();
                System.out.println("Enter Seat numbers:");
                Scanner scan = new Scanner(System.in);
                while (scan.hasNext()) {
                    String s = scan.next();
                    int row = Integer.parseInt(s.toUpperCase().substring(0, 1));
                    char col = s.toUpperCase().charAt(1);
                    q.reserveSeat(row, col);
                }
    }
     
        public void buildSeats() {
            char seatLetter = 'A';
            for (int i = 0; i < seats.length; i++) {
                for (int j = 0; j < seats[i].length; j++)
                seats[i][j] = seatLetter++;
                seatLetter = 'A';
            }
    }
     
        public void printSeats() {
            System.out.println("Available Seats:");
            for (int i = 0; i < seats.length; i++) {
                System.out.print((i + 1) + " ");
                for (int j = 0; j < seats[i].length; j++)
                System.out.print(seats[i][j] + " ");
                System.out.println();
            }
    }
     
    //checks if the seat is available for selection
        public void reserveSeat(int row, char col) {
            String seatNo=String.valueOf(row)+col;
            if (checkAvailability(seatNo)) {
                reservedSeats.add(seatNo);
                for (int i = row - 1; i == row - 1; i++) {
                    for (int j = 0; j < seats[i].length; j++) {
                        if (seats[i][j] == col) {
                            seats[i][j] = 'X';
                        }
                    }
    }
        System.out.println(" Seat " + seatNo + " is Reserved ");
    }
        else
        System.out.println("Sorry! The Seat "+seatNo+" is NOT available.Please look up for another seat.");
        printSeats();
    }
     
        public boolean checkAvailability(String seatNo) {
            boolean available = true;
            for(int i=0;i<reservedSeats.size();i++){
                if(reservedSeats.get(i).equalsIgnoreCase(seatNo)){
                    available = false;
                }
            }
            return available;
        }
    }
    Last edited by JosAH; 01-18-2012 at 04:48 PM. Reason: added [code] ... [/code] tags

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,013
    Rep Power
    10

    Default Re: Better Documentation for this codes

    What exactly do you want us to do?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    doran_lum is offline Member
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default Re: Better Documentation for this codes

    Could you help to explain the codes better ? I'm trying to understand how this booking system works

    I know it uses 2D array to get the seats and then awaits for user to enter the seats it wants and react accordingly

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,172
    Rep Power
    20

    Default Re: Better Documentation for this codes

    Ask whoever wrote it?

  5. #5
    doran_lum is offline Member
    Join Date
    Jan 2012
    Posts
    3
    Rep Power
    0

    Default Re: Better Documentation for this codes

    I would love it but I'm not too sure who's the author.. just trying to figure out this theatre seatings code

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,013
    Rep Power
    10

    Default Re: Better Documentation for this codes

    Quote Originally Posted by doran_lum View Post
    I would love it but I'm not too sure who's the author.. just trying to figure out this theatre seatings code
    What about it don't you understand? I suggest you step through it with a debugger, or at the very least use some print statements, to help you better understand what the program is doing.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Help using somone's documentation
    By davetheant in forum New To Java
    Replies: 12
    Last Post: 01-07-2011, 03:17 PM
  2. Making Documentation
    By Adam Cruge in forum New To Java
    Replies: 6
    Last Post: 04-11-2009, 08:02 PM
  3. min / max and documentation
    By jon80 in forum New To Java
    Replies: 1
    Last Post: 04-20-2008, 01:37 PM
  4. documentation
    By mcal in forum New To Java
    Replies: 4
    Last Post: 02-07-2008, 07:20 AM
  5. Java Documentation
    By ravian in forum New To Java
    Replies: 4
    Last Post: 12-04-2007, 10:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •