The Model
Create a Seat class that represents a seat at a stadium such that each seat is identified by 3 pieces of
information as follows: the section number (a byte from 1 to 4), the row letter (a char from 'A' to 'Z') and
the seat number within the row and section (a byte from 1 to 9). A seat must be identified by all three
pieces of information, for example, seat 4B8 would be the seat number 8 in section 4, row B. Each seat
has a cost according to the section. The seat costs are as follows: section 1 = $74, section 2 = $47,
section 3 = $32 and section 4 = $19. Make the following static constant in the Seat class to store
these: public static int[] PRICING = {74, 47, 32, 19}; Each seat may be purchased for up to 4
games/events. Add a boolean[] array that keeps track of whether or not the seat has been purchased
for any of the 4 games/events.
Create a Stadium class that maintains a 2 dimensional array of Seat objects. The array should be
exactly 35 columns by 27 rows in size. Not all of the locations in the grid represent seats. Some of the
locations represent aisles and the rink/stage area itself.
Get the following text files as off of the course webpage: "sections.txt", "rows.txt" and "numbers.txt".
The "sections.txt" file contains a layout of characters representing the section numbers for all seats:
Section:
333333333 333333333 333333333
333333333 333333333 333333333
333333333 333333333 333333333
3 22222222 2222222 22222222 3
33 2222222 2222222 2222222 33
33 2 2 33
33 22 1111111 11111 1111111 22 33
33 22 111111 11111 111111 22 33
44 22 1 11111 11111 11111 1 22 44
44 22 11 --------------- 11 22 44
44 22 111| |111 22 44
44 22 111| |111 22 44
111| |111
44 22 111| |111 22 44
44 22 111| |111 22 44
44 22 11 --------------- 11 22 44
44 22 1 11111 11111 11111 1 22 44
33 22 111111 11111 111111 22 33
33 22 1111111 11111 1111111 22 33
33 2 2 33
33 2222222 2222222 2222222 33
3 22222222 2222222 22222222 3
333333333 333333333 333333333
333333333 333333333 333333333
333333333 333333333 333333333
rows:
CCCCCCCCC FFFFFFFFF IIIIIIIII
BBBBBBBBB EEEEEEEEE HHHHHHHHH
AAAAAAAAA DDDDDDDDD GGGGGGGGG
Z BBBBBBBB DDDDDDD FFFFFFFF K
ZY AAAAAAA CCCCCCC EEEEEEE JK
ZY T H JK
ZY TS CCCCCCC FFFFF IIIIIII GH JK
ZY TS BBBBBB EEEEE HHHHHH GH JK
DC TS X AAAAA DDDDD GGGGG L GH AB
DC TS XW --------------- KL GH AB
DC TS XWV| |JKL GH AB
DC TS XWV| |JKL GH AB
XWV| |JKL
DC RQ XWV| |JKL IJ AB
DC RQ XWV| |JKL IJ AB
DC RQ XW --------------- KL IJ AB
DC RQ X SSSSS PPPPP MMMMM L IJ AB
XW RQ TTTTTT QQQQQ NNNNNN IJ LM
XW RQ UUUUUUU RRRRR OOOOOOO IJ LM
XW R J LM
XW OOOOOOO MMMMMMM KKKKKKK LM
X PPPPPPPP NNNNNNN LLLLLLLL M
TTTTTTTTT QQQQQQQQQ NNNNNNNNN
UUUUUUUUU RRRRRRRRR OOOOOOOOO
VVVVVVVVV SSSSSSSSS PPPPPPPPP
numbers:
123456789 123456789 123456789
123456789 123456789 123456789
123456789 123456789 123456789
5 12345678 1234567 12345678 1
44 1234567 1234567 1234567 12
33 7 1 23
22 66 1234567 12345 1234567 12 34
11 55 123456 12345 123456 23 45
88 44 9 12345 12345 12345 1 34 11
77 33 87 --------------- 12 45 22
66 22 765| |123 56 33
55 11 654| |234 67 44
543| |345
44 76 432| |456 11 55
33 65 321| |567 22 66
22 54 21 --------------- 78 33 77
11 43 1 54321 54321 54321 9 44 88
54 32 654321 54321 654321 55 11
43 21 7654321 54321 7654321 66 22
32 1 7 33
21 7654321 7654321 7654321 44
1 87654321 7654321 87654321 5
987654321 987654321 987654321
987654321 987654321 987654321
987654321 987654321 987654321
Notice that some characters are spaces, dashes or vertical bars. These are aisle and rink/stage
locations and so they do not contain seats. The "rows.txt" file contains a similarly laid out set of
characters representing the row letters. The "numbers.txt" file contains yet another arrangement of
numbers representing the seat numbers. In the constructor for the Stadium, you should read in these
three files and populate the grid (i.e., 2D array) with new Seat objects whose section, row and seat
number match the data in the files. Below is what the files look like. (Hint: You can use two nested FOR loops,
each time through you should read one char from each file (representing the same location), then construct the Seat object
using these 3 chars as section, row and number (with appropriate conversions)).
You may want to create a temporary test method in the Stadium class so as to see whether you loaded
the files and created the Seat information correctly after creating a new Stadium.
so how can i help you ? I mean this looks like an programming assignment and if you tell what kind of help you're expecting I can be more helpful .
ok first of all here comes the parsing stuff . you can parse the data in text to arrays ( 3 arrays i guess section , row number etc.. ) and after parsing call the constructor of seat class to instantiate seat objects with parsed data . Btw i guess you can skip the non-wanted stuff like "|" etc. when parsing . Then comes creating a Stadium object which consists of seats , you can use array of seats in that case i guess .
I hope it can be helpful in starting![]()
ok lets think that way :
-- import vector module java.xxx.vector ( i dont remember exactly lang,util sth like that )
import java.xxx.Vector ;
-- create three vector objects by using "new" keyword and dont forget to type <char> for character vectors .
Vector charVector = new Vector<char>() ;
-- parse each text file to the vectors and do not forget to skip unwanted characters like "\n" , tab or "|" . ( you can define a bool returning utility function which is called isValidChar(char ch) maybe . ) and if the char. is valid then just parse it . At the end of parsing each file all the vectors should be of the same size .
-- Then it comes calling the constructors . < I assume you've coded the class >
Even though you haven't coded it may be sth like that :
class Seat {
int sectionNo ;
char rowLetter ;
int seatNo;
Seat(int secNo , int seat , char rowLet )
{
sectionNo = secNo ;
seatNo=seat ;
rowLetter = rowLet ;
}
// other funcs.
}
Please don't copy the functions , I just wrote them for you to have a general idea about what i've been talking from the beginning . Don't hesitate to ask anything
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks