Question refer to the Ticket and Transaction classes below.
public class Ticket
{
private String row;
private int seat;
private double price;
//constructor
public Ticket(String aRow, int aSeat, double aPrice)
{
row = aRow;
seat = aSeat;
price = aPrice;
}
//accessors getRow(), getSeat(), and getPrice()
...
}
public class Transaction
{
private int numTickets;
private Ticket[] tickList;
//constructor
public Transaction(int numTicks)
{
numTickets = numTicks;
tickList = new Ticket[numTicks];
String theRow;
int theSeat;
double thePrice;
for (int i = 0; i < numTicks; i++)
{
< read user input for theRow, theSeat, and thePrice >
...
/* more code */
}
}
/** @return total amount paid for this transaction */
public double totalPaid()
{
double total = 0.0;
/* code to calculate amount */
return total;
}
}
Which represents correct /* code to calculate amount */ in the totalPaid method?
(A)
for (Ticket t : tickList)
total += t.price;
(B)
for (Ticket t : tickList)
total += tickList.getPrice();
(C)
for (Ticket t : tickList)
total += t.getPrice();
(D)
Transaction T;
for (Ticket t : T)
total += t.getPrice();
(E)
Transaction T;
for (Ticket t : T)
total += t.price;