![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
I have no problem with your asking for clarification, that's often needed. Your following post, well.... If pointing out the need for clarity, as well as suggesting some places to peer into, was enough to 'scare him away', it doesn't bode well for his teachability. Just sayin', as the OP hasn't suggested that at all.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#12 |
|
Sexy Programmer
|
Not enough members read the forum faqs and rules. It's their own fault, if they don't receive a reply when asking for help but instead being corrected. One expects help and doesn't do their part , this irritates me as well as you.
__________________
I would love to change the world, but they won't give me the source code! |
|
|
|
|
|
#13 |
|
Programmer
Join Date: Oct 2005
Posts: 52
Rep Power: 4
![]() |
Your're both right in the fact that not enough people read the posting rules not only in this forum but for any forum for that matter. And you didnt' scare me away I just realized after reading all your comments and replies that I clearly didn't know enough about arrays or for loops to pose a question in the correct fashion so i spent the rest of last night reading and trying to learn something about the two topics. And sry again for not being clear....i need to make a program that outputs:
1 A B C D 2 A B C D 3 A B C D 4 A B C D 5 A B C D 6 A B C D 7 A B C D then after outputing this it should prompt the user for a choice of where they want to sit.(the assortment of letters and numbers are suppose to represent an airplane seating chart). |
|
|
|
|
|
#14 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Precisely how one would do it would depend on the language. This is the Java forum, and I really don't plan on going back to Java, but consider this approach:
Use a two-dimensional array for a seating plan, just as you've shown it. Initialize all the elements to blank. Output it, formatted, much as you have shown it. Move into your input loop. Accept as input a row/seat pair, and maybe a name. Map that row/seat pair to a row/column position in the array. Place something in that element; passenger name, big X, "occupado", whatever flips your skirt. Output it, formatted as before. My engineers actually produced something like this as part of a larger program back in about 1991. 'For' loops are simple. If you want an explanation, post back. It'll no doubt be virtually identical to what your learning materials say.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#15 |
|
Programmer
Join Date: Oct 2005
Posts: 52
Rep Power: 4
![]() |
Thanks for the advice it helped alot! I read back over what i had orignally and fixed up my for loops and array. Now i have this:
int[][] seat;
seat = new int[7][5];
int row, column;
for(row = 0; row < 7; row++){
for(column = 0; column < 5; column++){
seat[0][0] = 1;
seat[1][0] = 2;
seat[2][0] = 3;
seat[3][0] = 4;
seat[4][0] = 5;
seat[5][0] = 6;
seat[6][0] = 7;
System.out.print(seat[row][column]+ " ");
}
System.out.println();
}1 0 0 0 0 2 0 0 0 0 3 0 0 0 0 4 0 0 0 0 5 0 0 0 0 6 0 0 0 0 7 0 0 0 0 how would i replace the "0's" with letters if the array is of type int? |
|
|
|
|
|
#16 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Don't make it of type int. One can put text representations of numbers in a text container, but not vice versa. After all, your screen isn't showing an int, it's showing a presentational encoding of an int.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#17 | |
|
Caffeinated Neural Net
![]() Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,107
Rep Power: 5
![]() |
Quote:
In any case, you should be able to check the status, with a predefined value indicating vacancy. For data types of boolean, int, and String, you could use false, 0, and "" (empty text), respectively.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot. - Vaarsuvius, Order of the Stick |
|
|
|
|
|
|
#18 |
|
Expert Programmer
|
In your original post, you were displaying the seating chart as the letters A-D. I would use an array of chars, and print the row number (int row) before each line.
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|