Results 1 to 5 of 5
  1. #1
    Shizzle is offline Forizzle.
    Join Date
    Sep 2012
    Location
    usa
    Posts
    3
    Rep Power
    0

    Default 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default 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.

  3. #3
    Shizzle is offline Forizzle.
    Join Date
    Sep 2012
    Location
    usa
    Posts
    3
    Rep Power
    0

    Default Re: Confused about this one class

    ^Sure thing boss! Done and done.

  4. #4
    Shizzle is offline Forizzle.
    Join Date
    Sep 2012
    Location
    usa
    Posts
    3
    Rep Power
    0

    Default 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...

  5. #5
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: Confused about this one class

    Help with what?

    I see you have posted code but no question. Make it a specific question. "I need help with this" is neither a question nor specific.

Similar Threads

  1. Replies: 3
    Last Post: 01-23-2012, 11:13 AM
  2. Replies: 16
    Last Post: 01-16-2012, 10:47 PM
  3. A little confused (class variable scope?)
    By Vase in forum New To Java
    Replies: 11
    Last Post: 02-03-2011, 02:51 AM
  4. Calling a class and a little confused
    By Boomer1 in forum New To Java
    Replies: 1
    Last Post: 12-29-2009, 06:10 PM
  5. Yet another Wrapper Class confused guy.
    By JAdeline in forum New To Java
    Replies: 2
    Last Post: 08-15-2008, 04:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •