Advertisement
Guest User

Untitled

a guest
Feb 26th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. public class Cinema implements ICinema {
  2.    
  3.     public static ArrayList<Seat> arrayOfSeats;
  4.     public static CinemaException exception;
  5.  
  6.     @Override
  7.     public void init(int rows, int columns) throws ICinemaInitCinemaException {
  8.         arrayOfSeats = new ArrayList<>();
  9.         Seat seat = new Seat();
  10.         if((rows >= 1 && rows <= 26) && (columns >= 1 && columns <=100)) {
  11.             for(int i = 0; i < rows; i++ ) {
  12.                 for(int j = 1; j <= columns; j++) {
  13.                     seat.setRow(String.valueOf((char)(('A' + i))));
  14.                     seat.setColumn(String.valueOf(j));
  15.                     arrayOfSeats.add(seat);
  16.                 }
  17.             }
  18.         } else {
  19.             exception = new CinemaException();
  20.             throw new ICinemaInitCinemaException("Init error", exception);
  21.         }
  22.        
  23.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement