Skip to content

Instantly share code, notes, and snippets.

@perfectacle
Created July 8, 2019 13:37
Show Gist options
  • Save perfectacle/a5b1ae202e4d1dd3197b1b1fcc71bb6e to your computer and use it in GitHub Desktop.
Save perfectacle/a5b1ae202e4d1dd3197b1b1fcc71bb6e to your computer and use it in GitHub Desktop.
s83_w01_p01
public class TicketOffice {
private long amount;
private Theater theater;
private final List<Ticket> tickets = new ArrayList<>();
public TicketOffice(final long amount, final Theater theater) {
this.amount = amount;
this.theater = theater;
}
void setTheater(final Theater theater) {
this.theater = theater;
}
void addTicket(final Ticket ticket) {
this.tickets.add(ticket);
}
Ticket getTicketWithFee() {
final var ticket = getTicket();
amount += ticket.getFee();
return ticket;
}
Ticket getTicketWithNoFee() {
return getTicket();
}
private Ticket getTicket() {
return tickets.isEmpty() ? Ticket.EMPTY : tickets.remove(0);
}
long getTicketPrice() {
if(tickets.isEmpty()) return 0L;
return tickets.get(0).getFee();
}
}
@dotNetTree
Copy link

0점
수고하셨습니다. 불행하게도 작동을 확인할 수 없습니다. 아무래도 제가 사견을 밝히는 건 무례한 일이라 사견은 첨부하지 않습니다.
기타 토론하고 싶은 부분이 있으시면 제게 페북 메세지로 말 걸어주세요.

(제 페북 사이트는 https://www.facebook.com/seungchul.kang.39?ref=br_rs 입니다.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment