I had to make an array that counted the seating in a movie theater, the second class m2 represents another showtime. I do not know how to add both arrays together and print the result of the sum of these two arrays.
This the MovieSeats tester file:
public class MovieSeatsTester
{
public static void main(String[] args)
{
MovieSeats m = new MovieSeats(3,3);
MovieSeats m2 = new MovieSeats(3,3);
m.seating(0,0);
m.seating(0,1);
m.seating(1,0);
m.seating(2,2);
m.seating(2,2);
m2.seating(0,0);
m2.seating(0,0);
m.print();
m.reset();
m2.print();
m2.reset();
}
}
This is the MovieSeats file:
public class MovieSeats
{
private int attendance[][];
public MovieSeats()
{
}
public MovieSeats(int rows, int columns)
{
attendance = new int[rows][columns];
}
public void seating(int r, int c)
{
attendance[r][c] += 1;
}
public void print()
{
for (int r = 0; r < attendance.length; r++)
{
for (int c = 0; c < attendance.length; c++)
{
System.out.println("At row " + r + " col " + c + ", There are " + attendance[r][c] + " Sitting here.");
}
}
System.out.println();
}
public void reset()
{
for (int r = 0; r < attendance.length; r++)
{
for (int c = 0; c < attendance.length; c++)
{
attendance[r][c] = 0;
}
}
System.out.println();
}
}