class LotteryService {

  private final LotteryTicketRepository repository;
  private final LotteryEventLog notifications;
  private final WireTransfers wireTransfers;

  /**
   * Constructor.
   */
  @Inject
  public LotteryService(LotteryTicketRepository repository, LotteryEventLog notifications,
                        WireTransfers wireTransfers) {
    this.repository = repository;
    this.notifications = notifications;
    this.wireTransfers = wireTransfers;
  }

  /**
   * Submit lottery ticket to participate in the lottery.
   */
  public Optional<LotteryTicketId> submitTicket(LotteryTicket ticket) {<FILL_FUNCTION_BODY>}

  /**
   * Check if lottery ticket has won.
   */
  public LotteryTicketCheckResult checkTicketForPrize(
      LotteryTicketId id,
      LotteryNumbers winningNumbers
  ) {
    return LotteryUtils.checkTicketForPrize(repository, id, winningNumbers);
  }
}

    var playerDetails = ticket.getPlayerDetails();
    var playerAccount = playerDetails.getBankAccount();
    var result = wireTransfers.transferFunds(TICKET_PRIZE, playerAccount, SERVICE_BANK_ACCOUNT);
    if (!result) {
      notifications.ticketSubmitError(playerDetails);
      return Optional.empty();
    }
    var optional = repository.save(ticket);
    if (optional.isPresent()) {
      notifications.ticketSubmitted(playerDetails);
    }
    return optional;
  
<no_super_class>