Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

WRITE A JAVA PROGRAM Part 1) The Lottery Ticket Printer (15 marks) Your lottery ticket printer program should implement an abstract class called ticket (you

WRITE A JAVA PROGRAM

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 didnt 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

image text in transcribed

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 couldnt get the try-catch right away just use an if structure and come back to it later.

Part1) 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 iffrom pat 1 if you do it right). Your program should create two instances of ticket, one you feel like you can make it more user friendly Lottery Program Part2) 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 night away) The ticket checker will read in the file you created in part 1 and check it against a predetermined set of winning mumbers. 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 with the mumbers 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 Welcome to the lottery program! 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: Number 1 Number 2 Number 3 Number 4 Number 5 Number 6 WON THE JACKPOTII CONGRATS 23 42 Print Ticket rtery Checker 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.txf'which will contain the numbers the user picked. You didn't win, better luck next time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

More Books

Students also viewed these Databases questions

Question

By definition, IT does not include:

Answered: 1 week ago