Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
1.3 kB
2
Indexable
Never
package cinema;

public class Seats {
    private int total_rows;
    private int total_columns;
    private Seat[] available_seats;

    public int getTotal_rows() {
        return total_rows;
    }

    public void setTotal_rows(int total_rows) {
        this.total_rows = total_rows;
    }

    public int getTotal_columns() {
        return total_columns;
    }

    public void setTotal_columns(int total_columns) {
        this.total_columns = total_columns;
    }

    public Seat[] settAvaliable_seats(int total_rows, int total_columns) {
        Seat[] seats = new Seat[total_rows * total_columns];
        int tmp = 0;
        for (int i = 1; i <= total_rows; i++) {
            for (int j = 1; j <= total_columns; j++) {
                seats[tmp] = new Seat(i, j);
                tmp++;
            }
        }
        return seats;
    }

    public Seat[] getAvailable_seats() {
        return available_seats;
    }

    public void setAvailable_seats(Seat[] available_seats) {
        this.available_seats = available_seats;
    }

    public Seats(int total_rows, int total_columns) {
        this.total_rows = total_rows;
        this.total_columns = total_columns;
        setAvailable_seats(settAvaliable_seats(total_rows, total_columns));
    }
}