Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

MITS4002 OBJECT-ORIENTED SOFTWARE DEVELOPMENT Project (25%) Tattslotto 50% deduction for Late Submission within one week 0 mark for Late Submission more than one week 0 mark for duplicated Submission...

1 answer below »
MITS4002
OBJECT-ORIENTED SOFTWARE
DEVELOPMENT
Project (25%)
Tattslotto

50% deduction for Late Submission within one week
0 mark for Late Submission more than one week
0 mark for duplicated Submission or Shared Work
You will be marked based on your submitted zipped file on Moodle. You are
most welcome to check your file with your lab tutor before your submission.
No excuse will be accepted due to file co
uption, absence from lecture or lab
classes where details of lab requirements may be given.
Please make sure that you attend Lecture EVERY WEEK as low
attendance may result in academic penalty or failure of this unit.
MITS4002 Project

Copyright © XXXXXXXXXXVIT, All Rights Reserved. XXXXXXXXXXPage 2
Programming Project
Part 1: A
ays & Inheritance
Submission deadline: 5 pm, Monday, Lesson 12
Marks: The project is assessment for 25% of final mark for the subject. The project is
composed of two parts: Part 1 and Part 2.
Problem Description
This project is based on the design, and implementation in Java, of the seven different
Lottery games being Saturday Tattslotto, Oz Lotto and Powe
all.
Details of these games can be found at http:
www.thelott.com
In Part 1 of the project, you are asked to use a
ays and inheritance to code versions of
these games and in Part 2 to create an appropriate GUI that writes to a report file.
Note: GAMBLING can be a serious problem for some people.
Your lecturer DOES NOT encourage you to gamble.
Summary of Some of the Lottery Games
(From the Help pages of the above web site)
Game Day Description
Tattslotto Saturday 45 balls numbered 1 to 45, from which 8 balls are randomly
selected. The first 6 balls are the winning numbers and the last two
alls drawn are the supplementary numbers.
Oz Lotto Tuesday 45 balls numbered 1 to 45, from which 9 balls are randomly
selected. The first 7 balls are the winning numbers and the last two
alls drawn are the supplementary numbers.
Powe
all Thursday 35 balls numbered 1 to 35 from which 7 are randomly selected. An
eighth ball, the Powe
all, is then drawn from a separate machine
containing 20 balls numbered 1 to 20.
You will notice from your research and examination of the table that all games have several
things in common.
All games
• have a name,
• run on a day of the week
• have a set of randomly generated numbers.

Also, each of the randomly generated numbers have a minimum and maximum possible value,
for example: For Powe
all, the minimum value is 1 and the maximum value is 35.
An abstract class, LuckyGame can be used to represent the generic concept of a game of
chance. A suitable partial design is shown in the following UML diagram. In the UML diagram:
• The LuckyGame class represents the generic concept of a game of chance and
therefore is to be declared as an abstract class. It contains two abstract methods
MITS4002 Project

Copyright © XXXXXXXXXXVIT, All Rights Reserved. XXXXXXXXXXPage 3
setNumberOfRandoms( ) and collectUserInput (String input). The LuckyGame
class also contains an a
ay of String which is used to record the randomly generated
numbers used by each object of LuckyGame type.
• The class TattslottoGame is a LuckyGame and it thus should implement code for
LuckyGame’s two abstract methods as well as its own constructor and any other
methods.
• The games SaturdayTattslotto and Oz Lotto are all instances of the class
TattslottoGame.

• You can implement the remaining class games in any manner you believe appropriate.
For example, class PowerBallGame can be implemented using either using

o Option 1: the class PowerBallGame is a LuckyGame and thus should
implement code for LuckyGame’s two abstract methods as well its own
constructor and other methods.
o Option 2: the class PowerBallGame is a TattslottoGame and thus should
implement code for its own constructor and other methods.
• You have been provided with some code for the class TestGames, which is a text-based
application used to create instances of games and test all of their respective behaviours.
• To collect user input for all games, a class UserInput is needed. It should collect user
input and deal with any problems in the input, such as repeat numbers or numbers outside
the possible range of values.
MITS4002 Project

Copyright © XXXXXXXXXXVIT, All Rights Reserved. XXXXXXXXXXPage 4
UML Diagram
MITS4002 Project

Copyright © XXXXXXXXXXVIT, All Rights Reserved. XXXXXXXXXXPage 5
Code for TestGames

A class that tests the instances of each class of game
*************************************************************
*******
class TestGames
{ public static void main ( String [ ] args )
{
final int NO_OF_GAMES = 7 ;
LuckyGame [ ] games = new LuckyGame [NO_OF_GAMES];
TattslottoGame myGame = new TattslottoGame
("Tattslotto", "Saturday", 1 , 45 ) ;
TattslottoGame OzLotto = new TattslottoGame ( "OZ
Lotto", "Tuesday", 1, 45 ) ;
TattslottoGame WedsLotto = new TattslottoGame (
"Tattslotto", "Wednesday", 1, 40 ) ;
Tatts2Game tatts2 = new Tatts2Game ("Tatts2",
"everyday", 1 , 99 ) ;
PowerBallGame powerBall = new PowerBallGame
("PowerBall", "Thursday", 1 , 45 ) ;
……………………………………………………………………………………..
Super 66
instance
……………………………………………………………………………..
Pools instance
games[0] = myGame ;
games[1] = OzLotto ;
games[2] = WedsLotto ;
games[3] = tatts2 ;
games[4] = powerBall ;
……………………………………………………………………………………..
Super 66
instance
……………………………………………………………………………..
Pools instance
for (int i = 0 ; i < NO_OF_GAMES ; i++)
{ System.out.print
("\n\n*******************************************\n" );
System.out.print ("Input your numbers for " +
games[i].getDay( ) + " " + games[i].getName( ) + " :- " ) ;
String input = Keyboard.readString( ) ;
games[i].collectUserInput( input );
System.out.println ( games[i] ) ;
}
end for
}
end main
MITS4002 Project

Copyright © XXXXXXXXXXVIT, All Rights Reserved. XXXXXXXXXXPage 6
Sample output
An example of some output from a run of TestGames. NOTE: ALL OUTPUTS ARE ONLY
SUGGESTIONS and should be used as a guide to your implementations.
*******************************************
Input your numbers for Saturday Tattslotto : XXXXXXXXXX
Invalid input
Saturday Tattslotto numbers are:
XXXXXXXXXXsupplementary numbers: 25 38
6 user picks between 1 and 45 are
XXXXXXXXXX
No. of winners
Answered Same Day Oct 03, 2021 MITS4002

Solution

Aditi answered on Oct 21 2021
159 Votes
Solution/Document.docx
DOCUMENTATION
UML
Details
In this assignment, we developed 4 different following classes:
1. LuckyGame: This class represents a single lucky game in the assignment project. It is an abstract class and the subclasses of LuckyGame class will define the abstract methods of this abstract class. The data members and methods are accessible to the subclasses and it can be used as per the requirement. The following is the definition of the abstract class LuckyGame.
import java.util.Random;
abstract public class LuckyGame {

String gameName;
String dayOfGame;
int numberOfRandoms;
int lowerValue;
int higherValue;
String[] randomNumbers;
public LuckyGame(String gameName, String dayOfGame, int lowerValue, int higherValue) {
this.gameName = gameName;
this.dayOfGame = dayOfGame;
this.lowerValue = lowerValue;
this.higherValue = higherValue;
}

public void createRandomNumbers(){
Random random = new Random();
randomNumbers = new String[numberOfRandoms];
for(int i=0; i randomNumbers[i] = (random.nextInt(higherValue - lowerValue) + lowerValue) + "";
}
}
public String getName() {
return gameName;
}
public String getDay() {
return dayOfGame;
}
abstract public String toString();
abstract public void setNumberOfRandoms();
abstract public void collectUserInput (String input);

}
2. PowerBallGame: This class extends the abstract class LuckyGame. PowerBallGame class represents a single game for Power ball lucky game. It defines all the abstract methods of the super class and checks the winner of the game by randomly selecting the numbers. The winning numbers are then displayed on the screen also with the matches found between winning numbers and the user picks. The following is the definition of the class PowerBallGame:
import java.util.Random;
public class PowerBallGame extends LuckyGame{

private String theInput;
private String powerBall;
int userPicks;
public PowerBallGame(String gameName, String dayOfGame, int lowerValue, int higherValue) {
super(gameName, dayOfGame, lowerValue, higherValue);
this.theInput = "";
}

public String checkWinningNumbers(){
int winNum = 0;

String[] inputVals = theInput.split(" ");
for(int j=0; j < inputVals.length; j++){
for(int i=0; i if(inputVals[j].equals(randomNumbers[i]))
winNum++;
}
}

if(randomNumbers[numberOfRandoms-1].equals(powerBall))
return "No. of winners " + winNum + " you have the POWERBALL";
else
return "No. of winners " + winNum + " you dont have the POWERBALL";

}
@Ove
ide
public void setNumberOfRandoms() {
Random random = new Random();
numberOfRandoms = random.nextInt(5) + 5;
super.createRandomNumbers();
}
@Ove
ide
public void collectUserInput(String input) {
this.theInput = input;
String[] val = input.split(" ");
this.userPicks = val.length;
this.powerBall = val[val.length-1];
this.setNumberOfRandoms();
}
@Ove
ide
public String toString() {
String s = this.getDay() + " " + this.getName() + " numbers are: \n";
for(int i=0; i s += randomNumbers[i] + " ";
}
s += "the POWERBALL is:- " + randomNumbers[numberOfRandoms-1] + "\n";
s += this.userPicks + " user picks between " + lowerValue + " and " + higherValue + " are\n";
s += this.theInput + " and the user chosen POWERBALL is:- " + powerBall + "\n";
s += checkWinningNumbers();
return s;
}
}
3. TattslottoGame: This class extends the abstract class LuckyGame. TattslottoGame class represents a single game for Tatts lotto lucky game. It defines all the abstract methods of the super class and checks the winner of the game by randomly selecting the numbers. The winning numbers are then displayed on the screen also with the matches found between winning numbers and the user picks. The following is the definition of the class TattslottoGame:
import...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here