Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Java Error
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Jeefer




PostPosted: Tue May 18, 2004 2:01 pm   Post subject: Java Error

I'm trying to get a class to call a class, although it keeps coming up with the error:
Quote:
The method "draw" is not static, and cannot be accessed in this static context.


I'm not sure what to change though inorder to fix this error...

Here is the method that it keeps coming up in: (it comes up at each of the instances of [b] drawcard.draw(number, xposition, yposition);

--Jeefer
Sponsor
Sponsor
Sponsor
sponsor
Jeefer




PostPosted: Tue May 18, 2004 2:01 pm   Post subject: Java Error

code:

public void Shuffle ()
    {
        int number = -1;
        int count = 0;
        drawCards blah = new drawCards (c);
        while (true)
        {
            number = (int) (Math.floor (Math.random () * 13));
            if (number == 0 && counter_sorry != 4)
            {
                counter_sorry++;
                count++;
                drawCards.draw (0, 100, 100);
            }
            else if (number == 1 && counter_one != 5)
            {
                counter_one++;
                count++;
                drawCards.draw (1, 100, 100);
            }
            else if (number == 2 && counter_two != 4)
            {
                counter_two++;
                count++;
                drawCards.draw (2, 100, 100);
            }
            else if (number == 3 && counter_three != 4)
            {
                counter_three++;
                count++;
                drawCards.draw (3, 100, 100);
            }
            else if (number == 4 && counter_four != 4)
            {
                counter_four++;
                count++;
                drawCards.draw (4, 100, 100);
            }
            else if (number == 5 && counter_five != 4)
            {
                counter_five++;
                count++;
                drawCards.draw (5, 100, 100);
            }
            else if (number == 7 && counter_seven != 4)
            {
                counter_seven++;
                count++;
                drawCards.draw (7, 100, 100);
            }
            else if (number == 8 && counter_eight != 4)
            {
                counter_eight++;
                count++;
                drawCards.draw (8, 100, 100);
            }
            else if (number == 10 && counter_ten != 4)
            {
                counter_ten++;
                count++;
                drawCards.draw (10, 100, 100);
            }
            else if (number == 11 && counter_eleven != 4)
            {
                counter_eleven++;
                count++;
                drawCards.draw (11, 100, 100);
            }
            else if (number == 12 && counter_twelve != 4)
            {
                counter_twelve++;
                count++;
                drawCards.draw (12, 100, 100);
            }

            if (count == 45)
            {
                break;
            }
        }


the class that it is calling is:
code:

public void draw (int number, int xPosition, int yPosition)
    {
        int count = 0;
        Color orange = new Color (255, 132, 9);
        c.setColor (orange);
        c.fillRect (xPosition, yPosition, 100, 175); //card
        c.setColor (Color.black);
        c.drawRect (xPosition, yPosition, 100, 175); //card
        while (true)
        {
            card (number, xPosition, yPosition);
        }
    }


    public  void card (int number, int x, int y)
    {
        int wut2Draw;
        wut2Draw = number;
        switch (wut2Draw)
        {
            case 0:
                //F
                c.fillRect (x + 35, y + 15, 5, 30); //line down F
                c.fillRect (x + 35, y + 15, 20, 5); //top line F
                c.fillRect (x + 35, y + 30, 20, 5); //bottom line F
                //M
                c.fillRect (x + 30, y + 80, 5, 25);
                c.fillRect (x + 30, y + 80, 15, 5);
                c.fillRect (x + 45, y + 80, 5, 25);
                c.fillRect (x + 45, y + 80, 15, 5);
                c.fillRect (x + 60, y + 80, 5, 25);
                //M
                c.fillRect (x + 30, y + 140, 5, 25);
                c.fillRect (x + 30, y + 140, 15, 5);
                c.fillRect (x + 45, y + 140, 5, 25);
                c.fillRect (x + 45, y + 140, 15, 5);
                c.fillRect (x + 60, y + 140, 5, 25);

            case 1:
                c.fillRect (x + 5, y + 10, 5, 20); //top left 1
                c.fillRect (x + 92, y + 150, 5, 20); //bottom right 1
                //O
                c.fillRect (x + 15, y + 70, 7, 22);
                c.fillRect (x + 15, y + 70, 15, 7);
                c.fillRect (x + 30, y + 70, 7, 22);
                c.fillRect (x + 15, y + 92, 22, 7);
                //N
                c.fillRect (x + 40, y + 70, 7, 29);
                c.fillRect (x + 40, y + 70, 15, 10);
                c.fillRect (x + 55, y + 70, 7, 29);
                //E
                c.fillRect (x + 65, y + 70, 7, 22);
                c.fillRect (x + 65, y + 70, 15, 7);
                c.fillRect (x + 65, y + 81, 15, 7);
                c.fillRect (x + 65, y + 92, 15, 7);
            case 2:
                //top left corner
                c.fillRect (x + 05, y + 10, 20, 5); //top portion of 2
                c.fillRect (x + 20, y + 10, 5, 10); //top first down 2
                c.fillRect (x + 05, y + 20, 20, 5); //middle 2
                c.fillRect (x + 05, y + 20, 5, 10); //bottom down 2
                c.fillRect (x + 05, y + 30, 20, 5); //bottom across 2

                //bottom right corner
                c.fillRect (x + 75, y + 140, 20, 5); //top portion of 2
                c.fillRect (x + 90, y + 140, 5, 10); //top first down 2
                c.fillRect (x + 75, y + 150, 20, 5); //middle 2
                c.fillRect (x + 75, y + 150, 5, 10); //bottom down 2
                c.fillRect (x + 75, y + 160, 20, 5); //bottom across 2
                //T
                c.fillRect (x + 10, y + 70, 25, 7);
                c.fillRect (x + 19, y + 70, 9, 28);
                //W
                c.fillRect (x + 40, y + 70, 5, 25);
                c.fillRect (x + 40, y + 90, 25, 8);
                c.fillRect (x + 50, y + 70, 5, 25);
                c.fillRect (x + 60, y + 70, 5, 25);
                //O
                c.fillRect (x + 70, y + 70, 7, 22);
                c.fillRect (x + 70, y + 70, 15, 7);
                c.fillRect (x + 85, y + 70, 7, 25);
                c.fillRect (x + 70, y + 92, 22, 7);
            case 3:
                //top left
                c.fillRect (x + 20, y + 10, 5, 25); //down 3
                c.fillRect (x + 5, y + 10, 20, 5); //top portion of 3
                c.fillRect (x + 5, y + 20, 20, 5); //middle 3
                c.fillRect (x + 5, y + 30, 20, 5); //bottom across 3

                //bottom right corner
                c.fillRect (x + 90, y + 140, 5, 25); //down 3
                c.fillRect (x + 75, y + 140, 20, 5); //top portion of 3
                c.fillRect (x + 75, y + 150, 20, 5); //middle 3
                c.fillRect (x + 75, y + 160, 20, 5); //bottom across 3
                //centre
                c.fillRect (x + 60, y + 65, 5, 30); //down 3
                c.fillRect (x + 40, y + 65, 25, 5); //top portion of 3
                c.fillRect (x + 40, y + 95, 25, 5); //middle 3
                c.fillRect (x + 40, y + 80, 25, 5); //bottom across 3

            case 4:
                //top left corner
                c.fillRect (x + 15, y + 10, 5, 25); //longest side of 4
                c.fillRect (x + 5, y + 20, 10, 5); //centre of 4
                c.fillRect (x + 5, y + 10, 5, 10); //smallest vertical section of 4

                //bottom right corner
                c.fillRect (x + 90, y + 140, 5, 25); //longest side of 4
                c.fillRect (x + 80, y + 150, 10, 5); //centre of 4
                c.fillRect (x + 80, y + 140, 5, 10); //smallest vertical section of 4

                //centre
                c.fillRect (x + 55, y + 65, 5, 35); //longest side of 4
                c.fillRect (x + 35, y + 80, 20, 5); //centre of 4
                c.fillRect (x + 35, y + 65, 5, 15); //smallest vertical section of 4
            case 5:

                c.fillRect (x + 05, y + 10, 25, 5); //top portion of 5
                c.fillRect (x + 5, y + 10, 5, 10); //top first down 5
                c.fillRect (x + 05, y + 20, 20, 5); //middle 5
                c.fillRect (x + 25, y + 20, 5, 15); //bottom down 5
                c.fillRect (x + 05, y + 30, 20, 5); //bottom across 5

                //bottom right corner
                c.fillRect (x + 70, y + 140, 25, 5); //top portion of 5
                c.fillRect (x + 70, y + 140, 5, 10); //top first down 5
                c.fillRect (x + 70, y + 150, 20, 5); //middle 5
                c.fillRect (x + 90, y + 150, 5, 15); //bottom down 5
                c.fillRect (x + 70, y + 160, 20, 5); //bottom across 5

                //centre
                c.fillRect (x + 35, y + 65, 30, 5); //top portion of 5
                c.fillRect (x + 35, y + 65, 5, 20); //top first down 5
                c.fillRect (x + 35, y + 80, 30, 5); //middle 5
                c.fillRect (x + 60, y + 80, 5, 20); //bottom down 5
                c.fillRect (x + 35, y + 95, 30, 5); //bottom across 5

            case 7:
                //top left corner
                c.fillRect (x + 15, y + 10, 5, 20); //top left 1
                c.fillRect (x + 5, y + 10, 10, 5); //top left 1
                //bottom right corner
                c.fillRect (x + 92, y + 150, 5, 20); //bottom right 1
                c.fillRect (x + 82, y + 150, 10, 5); //top left 1
                //centre
                c.fillRect (x + 32, y + 70, 25, 7);
                c.fillRect (x + 50, y + 70, 7, 32);

            case 8:
                c.fillRect (x + 20, y + 10, 5, 25); //down 8
                c.fillRect (x + 5, y + 10, 20, 5); //top portion of 8
                c.fillRect (x + 5, y + 20, 20, 5); //middle 8
                c.fillRect (x + 5, y + 30, 20, 5); //bottom across 8
                c.fillRect (x + 5, y + 10, 5, 25); //down 8

                //bottom right corner
                c.fillRect (x + 90, y + 140, 5, 25); //down 8
                c.fillRect (x + 75, y + 140, 5, 25); //down 8
                c.fillRect (x + 75, y + 140, 20, 5); //top portion of 8
                c.fillRect (x + 75, y + 150, 20, 5); //middle 8
                c.fillRect (x + 75, y + 160, 20, 5); //bottom across 8
                //centre
                c.fillRect (x + 40, y + 65, 5, 30); //down 8
                c.fillRect (x + 60, y + 65, 5, 30); //down 8
                c.fillRect (x + 40, y + 65, 25, 5); //top portion of 8
                c.fillRect (x + 40, y + 95, 25, 5); //middle 8
                c.fillRect (x + 40, y + 80, 25, 5); //bottom across 8

            case 10:

                c.fillRect (x + 5, y + 10, 5, 20); //top left 1

                c.fillRect (x + 15, y + 25, 15, 5); //top portion of 0
                c.fillRect (x + 15, y + 10, 5, 20); //left down 0
                c.fillRect (x + 15, y + 10, 15, 5); //bottom 0
                c.fillRect (x + 25, y + 10, 5, 20); //right down 0
                //bottom right corner
                c.fillRect (x + 72, y + 150, 5, 20); //bottom right 1

                c.fillRect (x + 82, y + 150, 15, 5); //top portion of 0
                c.fillRect (x + 82, y + 150, 5, 20); //left down 0
                c.fillRect (x + 82, y + 165, 15, 5); //bottom 0
                c.fillRect (x + 92, y + 150, 5, 20); //right down 0
                //centre
                c.fillRect (x + 30, y + 65, 5, 30); //1

                c.fillRect (x + 40, y + 65, 25, 5); //top portion of 0
                c.fillRect (x + 40, y + 65, 5, 30); //left down 0
                c.fillRect (x + 40, y + 90, 25, 5); //bottom 0
                c.fillRect (x + 60, y + 65, 5, 30); //right down 0

            case 11:
                //top left corner
                c.fillRect (x + 5, y + 10, 5, 20); //left 1
                c.fillRect (x + 15, y + 10, 5, 20); //right 1


                //bottom right corner
                c.fillRect (x + 72, y + 150, 5, 20); //bottom left 1
                c.fillRect (x + 82, y + 150, 5, 20); //right 1


                //centre
                c.fillRect (x + 40, y + 65, 5, 30); //left 1
                c.fillRect (x + 55, y + 65, 5, 30); //right 1
            case 12:
                c.fillRect (x + 5, y + 10, 5, 25); //left 1

                c.fillRect (x + 15, y + 10, 20, 5); //top portion of 2
                c.fillRect (x + 30, y + 10, 5, 10); //top first down 2
                c.fillRect (x + 15, y + 20, 20, 5); //middle 2
                c.fillRect (x + 15, y + 20, 5, 10); //bottom down 2
                c.fillRect (x + 15, y + 30, 20, 5); //bottom across 2




                //bottom right corner
                c.fillRect (x + 67, y + 145, 5, 25); //bottom left 1

                c.fillRect (x + 77, y + 145, 20, 5); //top portion of 2
                c.fillRect (x + 92, y + 145, 5, 10); //top first down 2
                c.fillRect (x + 77, y + 155, 20, 5); //middle 2
                c.fillRect (x + 77, y + 155, 5, 10); //bottom down 2
                c.fillRect (x + 77, y + 165, 20, 5); //bottom across 2

                //centre
                c.fillRect (x + 40, y + 65, 5, 35); //left 1

                c.fillRect (x + 50, y + 65, 20, 5); //top portion of 2
                c.fillRect (x + 65, y + 65, 5, 15); //top first down 2
                c.fillRect (x + 50, y + 80, 20, 5); //middle 2
                c.fillRect (x + 50, y + 80, 5, 15); //bottom down 2
                c.fillRect (x + 50, y + 95, 20, 5); //bottom across 2
            default:
                break;

        }
    }
Jeefer




PostPosted: Tue May 18, 2004 2:04 pm   Post subject: Java Error

If anyone could help, it would be greatly appreciated
Dan




PostPosted: Tue May 18, 2004 4:23 pm   Post subject: (No subject)

Well this dose not seem like prue java to me, witch makes it increably hard to help when i can not run the code or even debug it.

Tho, ready to progam is messed up it is still based on java so if it it anything like the real thing i think the problem is that you are calling the class by saying drawCards.draw() insted of blah.draw() witch you created the object as.

so replace all the drawCards.draw() with blah.draw() and i think it should work, i can not be shure tho b/c i only uses prue java. This hole c (console) thing confuses me, i dont get why holth whould add such a thing that olny complates things and makes the progames not work with real java Thinking
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: