This site requires JavaScript, please enable it in your browser!
Greenfoot back
Konzuk
Konzuk wrote ...

2014/10/22

BlackJack Tutorial

Konzuk Konzuk

2014/10/22

#
Can anyone teel me the correct Black Jack Card, Deck, adn Table coding? I can't find how to fix the mistakes anywhere else
danpost danpost

2014/10/22

#
Maybe you are not aware of how the discussions work. You need to provide what code you are having problems with and we will attempt to assist you in correcting it the best we can with what information you provide.
Konzuk Konzuk

2014/10/23

#
Sorry, never used this before, thought that's kind of common sense. public class deck {card.Colour colour; int spaces; int clubs; int hearts; int diamonds;} public class deck { this.colour = colour; this.diamonds = diamonds; this.clubs = clubs; this.spades = spades; this.hearts = hearts; setColour(); fill(); shuffle(); } on the first this.colour = colour, it's telling me it's an illegal start of type but I con't figure out how to fix it
danpost danpost

2014/10/24

#
Your first line starts the class with a '{' and also ends it with '}'. Then, it appears you are defining another class with the same name on the next line. I cannot tell from what is given exactly what you intended this code to do. However, it looks like you were trying to pass data to the class for use within it. I think you wanted to pass data to its constructor so the deck object created could use those values. In that case, your code should start like such:
public class deck
{
    // define instance fields
    card.Colour colour;
    int spaces, clubs, spades, hearts;

    // code block called when a new deck is created
    public deck(card.Colour colour, int spaces, int clubs, int hearts, int diamonds)
    {
        this colour = colour;
        // etc.
    }
}
Line 1 declares the class and line 3 heads the constructor of the class, called when the class is instantiated (or, when an object is created from the class -- when 'new deck(...)' is called). Notice the entire class is enclosed within curly brackets -- the fields, constructors, and methods.
Konzuk Konzuk

2014/10/24

#
thank you! It finally works ^^
You need to login to post a reply.