Created
July 8, 2019 13:37
-
-
Save perfectacle/a5b1ae202e4d1dd3197b1b1fcc71bb6e to your computer and use it in GitHub Desktop.
s83_w01_p01
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0점
수고하셨습니다. 불행하게도 작동을 확인할 수 없습니다. 아무래도 제가 사견을 밝히는 건 무례한 일이라 사견은 첨부하지 않습니다.
기타 토론하고 싶은 부분이 있으시면 제게 페북 메세지로 말 걸어주세요.
(제 페북 사이트는 https://www.facebook.com/seungchul.kang.39?ref=br_rs 입니다.)