Results 1 to 6 of 6
- 01-18-2012, 03:12 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
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 03:48 PM. Reason: added [code] ... [/code] tags
- 01-18-2012, 03:15 PM #2
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!
- 01-18-2012, 03:27 PM #3
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
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
- 01-18-2012, 03:37 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Re: Better Documentation for this codes
Ask whoever wrote it?
- 01-18-2012, 04:00 PM #5
Member
- Join Date
- Jan 2012
- Posts
- 3
- Rep Power
- 0
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
- 01-18-2012, 04:02 PM #6
Re: Better Documentation for this codes
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
-
Help using somone's documentation
By davetheant in forum New To JavaReplies: 12Last Post: 01-07-2011, 02:17 PM -
Making Documentation
By Adam Cruge in forum New To JavaReplies: 6Last Post: 04-11-2009, 07:02 PM -
min / max and documentation
By jon80 in forum New To JavaReplies: 1Last Post: 04-20-2008, 12:37 PM -
documentation
By mcal in forum New To JavaReplies: 4Last Post: 02-07-2008, 06:20 AM -
Java Documentation
By ravian in forum New To JavaReplies: 4Last Post: 12-04-2007, 09:45 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks