Assignment #5 Lottery Program solution


Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment


5/5 - (5 votes)

For this assignment you will be designing a lottery program that will both “print” and “check” a lottery ticket. The rules of the lottery game can be similar to the Canada wide lottery game, 6/49. The rules of the game are that a user picks 6 unique numbers between 1 and 49. If all of the 6 numbers match you win the jackpot. (you can also code if you get some of the numbers right you get a smaller portion of the prize, or a free ticket to try again). Your assignment will consist of two parts, Part A) the Printer and Part B) the Checker. Notes: Feel free to make these two separate java projects with two different main methods. If you feel the need to separate it out more than that then by all means, but please include all of the necessary classes to make your program work and give a heads up to whoever is marking how to make it work.
Part 1) The Lottery Ticket Printer (15 marks) Your lottery ticket printer program should implement an abstract class called ticket (you will write this class). This class should contain all of the private variables that will store the values of the lottery ticket. It should also contain all the appropriate set and get functions for these variables, as well as any helper functions. Your program should implement a GUI. The GUI should allow the user to enter 6 numbers (you can use text fields for these) Something similar to the functionality of this, but feel free to modify it if you feel like you can make it more user friendly.
The program should check to make sure that the user not only entered valid integers between 1-49, but also that each number is UNIQUE. It should do this by throwing exceptions if the user didn’t put in a proper value in the field, or if they tried to pick the same number twice. If the user entered valid input it should then save the numbers in a file called “ticket.txt” which will contain the numbers the user picked.
Part 2) The Lottery Ticket Checker (15 marks)
Your Lottery checker program should ask the user to input a file (you can have it have a GUI to ask the user to input a file by clicking a button or you can just bring up the file chooser right away) The ticket checker will read in the file you created in part 1 and check it against a predetermined set of winning numbers. The way it should do this is that it should have a ticket class that extends the comparable type (this can be the same class from part 1 if you do it right). Your program should create two instances of ticket, one with the numbers that were read in from the file selected and one with the “winning” numbers, and you should do a compare between these two objects. If the ticket numbers read in from the file match the winning tickets you should use your artistic graphic abilities to draw a winning message to the user telling them they won the jackpot. The graphic should use at least 3 different shapes and have an appropriate message. If the user does not have a winning ticket you should draw a losing message using at least 3 different shapes with an appropriate message, something like the below:
Notes: ● You can structure the file however you like, but it just needs to store the numbers ● as previously stated if you know how you can make them one project or you can submit these as two different java application projects. ● You can change the game around a little bit if 6 numbers is too ambitious (pick 3), the main point is that I want you to be able to write and check if they won or not.
● When checking the “winning numbers” you should also be able to handle if the user picks them out of order, for example if they chose 5, 4, 3, 2, 1 and the winning numbers are 1,2,3,4,5 they should still win ● I very much recommend if you have problems with one part of the assignment that you just stub that part out and continue working on the parts you know how to do. (for example, if you had problems with the file i/o then just hardcode the numbers in your program, or if you couldn’t get the try-catch right away just use an if structure and come back to it later.