For more information open this link http://people.scs.carleton.ca/~lanthier/teac
ID: 3616607 • Letter: F
Question
For more information open this linkhttp://people.scs.carleton.ca/~lanthier/teaching/COMP1406/Assignments/COMP1406_A2_W10.pdf
(1) The Model
Create a Seat class that represents a seat at a stadium such thateach 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). Aseat must be identified by all three
pieces of information, for example, seat 4B8 would be the seatnumber 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 staticconstant in the Seat class to store
these: public static int[] PRICING = {74, 47, 32, 19}; Each seatmay be purchased for up to 4
games/events. Add a boolean[] array that keeps track of whether ornot the seat has been purchased
for any of the 4 games/events.
Create a Stadium class that maintains a 2 dimensional array of Seatobjects. The array should be
exactly 35 columns by 27 rows in size. Not all of the locations inthe 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".
Section.txt
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.txt"
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.txt"
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
The "sections.txt" file contains a layout of charactersrepresenting the section numbers for all seats:
sections.txt rows.txt numbers.txt
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" filecontains a similarly laid out set of
characters representing the row letters. The "numbers.txt" filecontains yet another arrangement of
numbers representing the seat numbers. In the constructor for theStadium, you should read in these
three files and populate the grid (i.e., 2D array) with new Seatobjects whose section, row and seat
number match the data in the files. Below is what the files looklike. (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 Seatobject
using these 3 chars as section, row and number (with appropriateconversions)).
You may want to create a temporary test method in the Stadium classso as to see whether you loaded
the files and created the Seat information correctly after creatinga new Stadium.
Explanation / Answer
This is...quite a large program...I'll help youwith writing the Seat and Stadium classes. publicclass Seat { // constants publicstatic final int[] PRICING= {74, 47, 32, 19}; // instancevariables privatebyte section_number; privatechar row_letter; privatebyte seat_number; privateboolean[] purchased; //constructors // default public Seat() { purchased = new boolean[4]; } publicSeat(int section, char row, intseat) { this(); setSectionNumber(section); setRowLetter(row); setSeatNumber(seat); } // takes parameter inform 4B8 publicSeat(String data) { this(); setSectionNumber(Integer.parseInt(""+data.charAt(0))); setRowLetter(data.charAt(1); setSeatNumber(Integer.parseInt(""+data.charAt(2))); } // modifiers publicvoid setSectionNumber(int num) { section_number= (byte)num; } publicvoid setRowLetter(char c) { row_letter = c; } publicvoid setSeatNumber(int num) { seat_number = (byte)num; } publicvoid setPurchased(int event, booleanp) { purchased[event]= p; } // accessors publicbyte getSectionNumber() { return section_number; } publicchar getRowLetter() { return row_letter; } publicbyte getSeatNumber() { return seat_number; } publicboolean isPurchased(int event) { return purchased[event]; } publicdouble getCost() { return PRICING[section_number]; } publicString toString() { return ""+section_number+row_letter+seat_number; } } publicclass Stadium { private Seat[][]seats; publicStadium() { seats = newSeat[35][27]; } }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.