Results 1 to 5 of 5
Thread: Confused about this one class
- 09-16-2012, 03:45 AM #1
Forizzle.
- Join Date
- Sep 2012
- Location
- usa
- Posts
- 3
- Rep Power
- 0
Confused about this one class
Hey all,
First and foremost, my sincere apologies if I posted this in the wrong section (even if it appears right to me, I am rushing since I'm on a time limit).
I'm working on a bingo game project and I'm really struggling with it. I'll show you what I have so far; I'm using Eclipse btw:
Java Code://In the BingoBall class: public class BingoBall { //instance variables private char nLetter; private int bNum; public BingoBall(int randomNum) { bNum = randomNum; if (randomNum <= 15) nLetter = 'B'; else if (randomNum <= 30) nLetter = 'I'; else if (randomNum <= 45) nLetter = 'N'; else if (randomNum <= 60) nLetter = 'G'; else if (randomNum <= 75) nLetter = 'O'; } //accessor methods public char getLetter() { return nLetter; } public int getNum() { return bNum; } //toString method public String toString() { return (nLetter + " " + bNum); } } ----- public class BallCage public class BallCage { private boolean isTaken; private int numBallsAlive; private String temp; BingoBall[] ballCage; ballCage = new BingoBall[75]; //method returning a random bingo ball. (Assuming it's accessor method) public String getBingoBall() { return BingoBall; } //^ This is all kinds of wrong here, I'm sure >_>' //method returning the remaining number of bingo balls public int numBallsAlive() { //I'm guessing some kind of if statement and for loop would //be here... return numBallsAlive; } public String toString() { return temp; } }
Some background info:
There are 75 bingo balls. The bingo balls are stored in a cage. During play, a ball is selected at random from the cage, G 51 for example. Each player reviews his card to see if he has that number. If the player’s card contains the number called, he marks it by placing a small item, such as a red, transparent disc on their card. The center location is a “free” spot and all players mark this spot as taken at the beginning of the game. Play continues until one (or more) players have disks covering all numbers in a row or a column. Diagonals don't count right now, not sure if it will in the future (this thing I'm working on is "part 1," let's just focus on that, haha)
What I'm supposed to do for the BallCage Class:
An instance of a BallCage class should store the number of balls in the cage and a reference to a BingoBall array which stores references to the bingo balls in the cage. The BallCage class should provide the following:
A default constructor which creates the array and the 75 bingo balls to be stored in the array. The variable that stores the number of balls should be initialized accordingly.
A method which returns a random bingo ball.
A method which returns the number of bingo balls remaining in the cage.
A toString method which returns a string containing all the bingo balls in the cage. Needed for testing purposes.
It's the BallCage class that's really got me here. The App class(didn't post it here, it's empty so far) I should be able to figure out on my own.
The deadline for this thing is less than 16 hours away...and most of my morning will be gone as I go to church in the morning. Woes of a college student :<Last edited by Shizzle; 09-16-2012 at 05:05 AM.
-
Re: Confused about this one class
I would start by trying to create the constructors and methods listed in the instructions. You can't hurt anything by trying, and then if you're still stuck, post your attempt and we'll have a much better chance of being able to help you.
Also, if you post code, please wrap the code in [code] [/code] tags, not [quote] [/quote] tags as you have done above.
- 09-16-2012, 05:03 AM #3
Forizzle.
- Join Date
- Sep 2012
- Location
- usa
- Posts
- 3
- Rep Power
- 0
Re: Confused about this one class
^Sure thing boss! Done and done.
- 09-17-2012, 06:27 AM #4
Forizzle.
- Join Date
- Sep 2012
- Location
- usa
- Posts
- 3
- Rep Power
- 0
Re: Confused about this one class
Err, not to be a bother, but even if my hw is past due, I still need some help on this...
- 09-17-2012, 07:13 AM #5
Similar Threads
-
Confused about 'out's in System class and PrintStream class
By fatabass in forum New To JavaReplies: 3Last Post: 01-23-2012, 11:13 AM -
Calling a method from another class? *confused and stressed*
By Illanair in forum New To JavaReplies: 16Last Post: 01-16-2012, 10:47 PM -
A little confused (class variable scope?)
By Vase in forum New To JavaReplies: 11Last Post: 02-03-2011, 02:51 AM -
Calling a class and a little confused
By Boomer1 in forum New To JavaReplies: 1Last Post: 12-29-2009, 06:10 PM -
Yet another Wrapper Class confused guy.
By JAdeline in forum New To JavaReplies: 2Last Post: 08-15-2008, 04:04 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks