Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package h02;
- public class LotteryTicket {
- /**
- * Holds information about tickets status.
- *
- */
- private boolean isValid = true;
- /**
- * Tickets nr1.
- */
- private int nr1;
- /**
- * Tickets nr2.
- */
- private int nr2;
- /**
- * Holds ticket nr.
- */
- private long ticketNr;
- /**
- * Sets tickets data.
- *
- * @param nr1
- * - nr1.
- * @param nr2
- * - nr2.
- * @param ticketNr
- * - tickets serial number.
- */
- public LotteryTicket(int nr1, int nr2, long ticketNr) {
- this.nr1 = nr1;
- this.nr2 = nr2;
- this.ticketNr = ticketNr;
- System.out.println("Olete ostnud pileti numbritega: '" + nr1 + "' ja '"
- + nr2 + "'. Pileti kood on '" + this.ticketNr + "'");
- }
- /**
- * Checks if ticket has won or not.
- *
- * @param n1
- * - number 1.
- * @param n2
- * - number 2.
- * @return ture or false.
- */
- public boolean didIwin(int n1, int n2) {
- if ((n1 == this.nr1 && n2 == this.nr2)
- || (n2 == this.nr1 && n1 == this.nr2)) {
- return true;
- }
- return false;
- }
- /**
- * Returns ticket nr.
- *
- * @return tickets serial number.
- */
- public long getTicketNr() {
- return this.ticketNr;
- }
- /**
- * Checks if ticket is valid.
- * @return true or false.
- */
- public boolean isValid() {
- return this.isValid;
- }
- /**
- * Toggles tickets validation.
- */
- public void toggleValid() {
- this.isValid = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement