1. Homepage
  2. Programming
  3. CS 1027 Computer Science Fundamentals II - Assignment 1: Bingo Simulator

CS 1027 Computer Science Fundamentals II - Assignment 1: Bingo Simulator

Engage in a Conversation
CanadaWestern UniversityCS 1027Computer Science Fundamentals IIBingo SimulatorJavaCS1027

Assignment 1 CourseNana.COM


CourseNana.COM

Learning Outcomes CourseNana.COM

In this assignment, you will get practice with: CourseNana.COM

  • Loops, arrays (int, boolean, and Object), conditionals
  • Creating and using Strings and constants
  • Creating and using classes and objects
  • Implementing constructor, toString methods, and other methods
  • Overloading a method

Introduction CourseNana.COM

Bingo is an exciting game of chance that involves a set of cards with an arrangement of numbers in a grid. Players will often have several cards to monitor and will mark the numbers that get called. A bingo caller will call randomly selected numbers slowly one after another until one of the players has a completed line on one of their cards. They indicate that they have a line by shouting out the word “Bingo!” If the player correctly has a line where each of the numbers was called, then they win some type of prize. Below is an example Bingo card. This card would be a winner if the numbers 6, 24, 37, 49, and 66 were called since that would form a line of 5 numbers in a row. Any row, column, or diagonal (the two main diagonals of 5 cells from one corner to an opposite corner) is a possible winning line. One thing to note of Bingo cards is that the middle of the grid contains a “free” square. So, the four lines that contain the middle square only need 4 other numbers to win instead of 5. To help direct players to where a number may be, the numbers a broken up into ranges of 15. The first range from 1 through 15 falls under the B and so instead of calling out the number 7, it would be announced as B-7. Similarly, 16 through 30 falls under the I so it would be called as I-16. There are variations of Bingo but this captures the game's essence. CourseNana.COM

We will be creating a Bingo Simulator. CourseNana.COM

CourseNana.COM

Provided testing file BingoTests.java CourseNana.COM

This file will help to check if your java Classes are implemented correctly. A similar file will be incorporated into Gradescope’s auto-grader. Passing all the tests within BingoTest.java does not necessarily mean that your code is correct. CourseNana.COM

Classes to Implement CourseNana.COM

For this assignment, you must implement two Java classes: BingoCard and BingoSim. Follow the guidelines for each one below. CourseNana.COM

In both these classes, you can (and should) implement more private (helper) methods, if you want to, but you may not implement more public methods. You may not add instance variables other than the ones specified below nor change the variable types or accessibility (i.e. making a variable public when it should be private). Penalties will be applied if you implement additional instance variables or change the variable types or modifiers from what is described here. CourseNana.COM

BingoCard.java CourseNana.COM

This class is used to represent a single Bingo Card. The class must have these private instance variables: CourseNana.COM

  • private int[][] card
  • private boolean[][] taken

Also, this class must contain the following constant: CourseNana.COM

public static final int[] MY_WINNER CourseNana.COM

o This constant array can be used with the BingoCard’s Constructor  to create a valid Bingo card that is a winner if the following sequence is drawn 73, 20, 23, 7, 32, 1, 16, 29, 68, 38, 52, 17 (there are many solutions...Is the entire sequence required to before a winner is found?) CourseNana.COM

The class must have the following public methods: CourseNana.COM

public BingoCard(int[] data) [constructor]
o Takesthelineardataandplacesitinthe2Darray,cardwhichshouldbea5by5 array. (note: data only contains 24 entries since the middle square contains no number)
o A2Dbooleanarraywhichis5by5storeswhethertheircorrespondingnumberin the card array has been drawn. Initially, these will be false except for the middle square which will be set to true. CourseNana.COM

public boolean isValid() CourseNana.COM

o Returnsfalseifthereisaduplicatedvalueorifanumberisplacedinthewrong column: for example, is if 25 was in the first column (B) instead of the second column (I). CourseNana.COM

o Returnstrue,otherwise CourseNana.COM

  • public void drawn(int number)
    o Updatesthetakenarray.Ifnumberispresentinthecardarray,the corresponding entry in taken is set to true. There will be at most one updated value.
  • public void drawn(int[] numbers)

o Updatesthetakenarray.Ifavalueispresentinthenumbersarray,isalso present in the card, its corresponding entry in taken is set to true. Many values of taken may be updated. CourseNana.COM

  • public void reset()
    o Thismethodresetsallthevaluesbacktotheiroriginalvalues(seeconstructor).
  • public boolean isAWinner()
    o Returnstrueifanyrow,column,ordiagonal(twelvepossiblelines)inthetaken array contains only true values

o Returnsfalse,otherwise CourseNana.COM

  • public int minToWin()
    o Returnstheminimumnumberofnumbersthatcouldbedrawnforthiscardtobe considered a winner.
  • public String toString()

o ReturnsaStringwiththecontentsofarrays,cardandtaken,thatexactly matches the format of given below. Note numbers in square brackets indicate that that number has been taken. CourseNana.COM

o SomespecificstofocusonwhenconstructingtheString:eachentryis4 characters with a space after it. Spaces surround non-taken numbers, whereas brackets surround the taken characters. Thus, there are 25 characters per line. Also note that numbers less than ten have a space in front of them. You can better see the format within the code of BingoTests.java CourseNana.COM

BINGO [14] 29 39 52 67 [ 2] 22 [35] 58 71 [ 6] [28] [FR] [47] [66] [ 4] [30] 32 [56] [62] CourseNana.COM

12 20 43 [48] 75 CourseNana.COM

BingoSim.java CourseNana.COM

This class is used to represent a Bingo Game Simulator. The class must have these private instance variables: CourseNana.COM

  • private int numCards
    o Storesthenumberofbingocardsinthesimulation
  • private boolean[] taken
    o Storeswhetherthenumberhasbeentakenornot
  • private BingoCard[] cards
    The class must have the following public methods:
  • public BingoSim(int max) [constructor]
    o SetsupanarrayofBingoCardstostoreatmostmaxcards o Initializes the taken array representing the numbers taken
  • public void addCard(BingoCard b)
    o PutsaBingoCardintothearrayprovidedthereisspace.Otherwise,doesnothing with b.
  • public String simulate(int[] sequence)

o Simulatesthebingonumbersbeingdrawnintheorderoftheparameter sequence. The simulation stops as soon as there is at least one winner. CourseNana.COM

o Returnsastringthatincludesallthedrawnnumbersinorderandbingocard status indicating of each card’s minimum number of numbers to win CourseNana.COM

public String toString()
o Returns a String representing the current status of the simulation. The status includes a list of all the numbers (same format as the BingoCard’s toString method), the number of numbers drawn, the min-to-win numbers for each bingo card in the simulation as well as the number of winners. CourseNana.COM

BINGO 1 16 31 [46] 61 2 [17] 32 47 62 3 18 33 48 63 4 [19] 34 49 [64] 5 20 35 50 65 6 [21] 36 51 [66] 7 22 37 52 [67] 8 23 [38] 53 68 CourseNana.COM

[ 9] 24 39 [54] [69] [10] 25 40 [55] 70 11 26 41 56 71 12 27 [42] 57 72 CourseNana.COM

13 28 43 58 [73] [14] 29 44 [59] 74 15 30 45 60 75 CourseNana.COM

# Drawn: 17
mins:2 1 3 1 2 3 0
# Winners: 1 out of 7
CourseNana.COM

Marking Notes CourseNana.COM

Functional Specifications CourseNana.COM

  • Does the program behave according to specifications?
  • Does it produce the correct output and pass all tests?
  • Are the classes implemented properly?
  • Does the program produces compilation or run-time errors on Gradescope?
  • Does the program fail to follow the instructions (i.e. changing variable types, etc.)

Non-Functional Specifications CourseNana.COM

  • Are there comments throughout the code (Javadocs or other comments)?
  • Are the variables and methods given appropriate, meaningful names?
  • Is the code clean and readable with proper indenting and white-space?
  • Including a "package" line at the top of a file will receive a penalty of 5%

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Canada代写,Western University代写,CS 1027代写,Computer Science Fundamentals II代写,Bingo Simulator代写,Java代写,CS1027代写,Canada代编,Western University代编,CS 1027代编,Computer Science Fundamentals II代编,Bingo Simulator代编,Java代编,CS1027代编,Canada代考,Western University代考,CS 1027代考,Computer Science Fundamentals II代考,Bingo Simulator代考,Java代考,CS1027代考,Canadahelp,Western Universityhelp,CS 1027help,Computer Science Fundamentals IIhelp,Bingo Simulatorhelp,Javahelp,CS1027help,Canada作业代写,Western University作业代写,CS 1027作业代写,Computer Science Fundamentals II作业代写,Bingo Simulator作业代写,Java作业代写,CS1027作业代写,Canada编程代写,Western University编程代写,CS 1027编程代写,Computer Science Fundamentals II编程代写,Bingo Simulator编程代写,Java编程代写,CS1027编程代写,Canadaprogramming help,Western Universityprogramming help,CS 1027programming help,Computer Science Fundamentals IIprogramming help,Bingo Simulatorprogramming help,Javaprogramming help,CS1027programming help,Canadaassignment help,Western Universityassignment help,CS 1027assignment help,Computer Science Fundamentals IIassignment help,Bingo Simulatorassignment help,Javaassignment help,CS1027assignment help,Canadasolution,Western Universitysolution,CS 1027solution,Computer Science Fundamentals IIsolution,Bingo Simulatorsolution,Javasolution,CS1027solution,