Results 1 to 8 of 8
  1. #1
    SecurityCop is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default Game using Java Applets

    Hey there, I'm currently enrolled in the grade 11 programming course at my highschool, and I'm having a bit of trouble getting the game I have to design to work. The game works by itself, as does the picture by itself. However, when I tried to run them after combining them, I tried a few things. Either the picture came up in the applet, or the game appeared in the regular text box. Or the applet appeared, but had nothing in it. I just need a bit of help, this is for bonus marks, I already have 100 on the assignment, but the graphics are typically not introduced until next year, so I will get a bonus 10% if I can figure it out.

    I'm going to paste the code into here, however, most of the game itself can be ignored seeing as the game works, I just guess I don't have the combination correct.

    Java Code:
    import java.io.*;
    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class AppletPicture extends Applet
    {
        Image picture;
        URL base;
        MediaTracker mt;
    
        public void init ()
        {
            mt = new MediaTracker (this);
            try
            {
                base = getDocumentBase ();
            }
            catch (Exception e)
            {
            }
            picture = getImage (base, "canada1.jpg");
            mt.addImage (picture, 1);
            try
            {
                mt.waitForAll ();
            }
            catch (InterruptedException e)
            {
            }
        }
        public void main (String [] args, Graphics g)
            throws java.io.IOException
        {
        
            g.drawImage (picture, 20, 20, this);
            g.drawImage (picture, 20, 140, 30, 40, this);
            System.out.println ("Welcome to my game! I'm not an actual person, just some lines of");
            System.out.println ("code that have been programmed into the game. But, I am here to help");
            System.out.println ("make your life easier. Let me explain the rules first.");
            System.out.println ();
            System.out.println ("In this game, I'm going to give you a clue, and you're going to have");
            System.out.println ("to guess which province I am talking about. I will start you at 100");
            System.out.println ("points. If you require another clue as to which province it is, you");
            System.out.println ("will have to pay me 100 points. I can only offer one clue for each");
            System.out.println ("question. After that, you are on your own. Each correct answer gets you 50");
            System.out.println ("points, so use your clues sparringly. Good luck and have fun!");
            System.out.println ("By the way, territories are NOT inlcuded in this game.");
            System.out.println ("Press enter to continue");
            BufferedReader br = new BufferedReader (new InputStreamReader (System.in));
            String answer = ("none");
            String playagain;
            playagain = ("yes");
            while (true)
            { //start while
                double c1 = 0.00; //number of questions asked
                double c2 = 0.00; //number of correct questions
                int c3 = 1; //decides whether or not you have asked for a hint already
                int score = 100;
                int gamenum = 1;
                answer = br.readLine ();
                gamenum = 1;
                while (true)
                {
                    if (gamenum == 1)
                    { //start if
                        c3 = 0;
                        System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                        System.out.println ("You currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Let's begin.");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province has the 'Spiritual Bear' as one of it's provincial animals.");
                        while (true)
                        { //start while
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, they are known the Mountain province.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("British Columbia") || answer.equalsIgnoreCase ("bc"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("\n\nThat is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
    
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end if
                    if (gamenum == 2)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nYou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province is known for growing potatoes.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, they are the smallest province");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Prince Edward Island") || answer.equalsIgnoreCase ("pei"))
                            { //start if
    
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end else if
                    if (gamenum == 3)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nYou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province is known for being very flat, even though they have");
                        System.out.println ("many rolling hills.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, they grow a large supply of wheat and");
                                        System.out.println ("other grains as well.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Saskatchewan") || answer.equalsIgnoreCase ("sk"))
                            { //start if
    
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end else if
                    if (gamenum == 4)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nYou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province is known for it's separatist views from the rest of Canada.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, the majority of the province speaks Canada's");
                                        System.out.println ("second national language.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Quebec") || answer.equalsIgnoreCase ("qc"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end else if
                    if (gamenum == 5)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province's capital suffered the largest man made non-nuclear explosion ever.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, this province means 'New Scotland' in latin.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Nova Scotia") || answer.equalsIgnoreCase ("ns"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end else if
                    if (gamenum == 6)
                    { //start else if
                        c3 = 0;
                        System.out.println ("You currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province used to have a hockey team in the NHL.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, this province's capital has the highest");
                                        System.out.println ("murder per capita rate in Canada.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Manitoba") || answer.equalsIgnoreCase ("mb"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end else if
                    if (gamenum == 7)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nYou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province has a large supply of crude oil.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, this province's motto is 'strong and free'.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Alberta") || answer.equalsIgnoreCase ("ab"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                ;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end else if
                    if (gamenum == 8)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nYou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province has a large supply of seafood, particularly shellfish.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, this province has a large amount of");
                                        System.out.println ("mainland as well as a large island as part of it.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Newfoundland") || answer.equalsIgnoreCase ("nf") || answer.equalsIgnoreCase ("Newfoundland and Labrador"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                        continue;
                    } //end else if
                    if (gamenum == 9)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nYou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province contains most of The Great Lakes.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        System.out.println ("\n\nHere is your hint, the capital of this province has nearly 6 million");
                                        System.out.println ("residents.");
                                        c3++;
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        score = score + 100;
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("Ontario") || answer.equalsIgnoreCase ("on"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
    
                        continue;
                    } //end else if
                    if (gamenum == 10)
                    { //start else if
                        c3 = 0;
                        System.out.println ("\n\nYou currently have " + score + " points.");
                        System.out.println ();
                        System.out.println ("Onto the next question");
                        System.out.println ();
                        System.out.println ("Alright, here is your question. Type");
                        System.out.println ("'hint' if you need a clue.");
                        System.out.println ();
                        System.out.println ("This province is called the 'loyalist' province.");
                        while (true)
                        {
                            answer = br.readLine ();
                            if (answer.equalsIgnoreCase ("hint"))
                            { //start else if
                                score = score - 100;
                                if (score >= 0)
                                { //start if
                                    if (c3 == 0)
                                    {
                                        c3++;
                                        System.out.println ("\n\nHere is your hint, the oldest city is Saint John, not to be");
                                        System.out.println ("confused with St. John's of Newfoundland.");
                                        continue;
                                    }
                                    if (c3 == 1)
                                    {
                                        System.out.println ("\n\nYou have already asked you a hint.");
                                        continue;
                                    }
                                } //end if
                                else if (score < 0)
                                { //start else if
                                    System.out.println ("\n\nI'm sorry, you don't have enough points for a clue.");
                                    score = score + 100;
                                    continue;
                                } //end if
                            } //end else if
                            if (answer.equalsIgnoreCase ("New Brunswick") || answer.equalsIgnoreCase ("nb"))
                            { //start if
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("That is correct! Good job, you get 50 points.");
                                score = score + 50;
                                gamenum++;
                                c1++;
                                c2++;
                                break;
                            } //end if
                            else
                            { // start else
                                System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                                System.out.println ("I'm sorry, but that is incorrect.");
                                c1++;
                                gamenum++;
                                break;
                            } //end else
                        } //end while loop
                    } //end else if
                    break;
                }
                if (gamenum == 11)
                {
                    System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                    double total = ((c2 / c1) * 100);
                    System.out.println ("You are done, let's see how you did: ");
                    System.out.println ("\n\n");
                    System.out.println ("You got " + total + "% correct");
                    System.out.println ("\n\n");
                    System.out.println ("You had " + score + " points left over.");
                    System.out.println ("\n\n");
                    if ((c2 / c1) * 100 == 100)
                    {
                        System.out.println ("Congrats, you got perfect! You definitely know Canada's provinces.");
                    }
                    else if ((c2 / c1) * 100 == 90)
                    {
                        System.out.println ("Good job, you did very well!");
                    }
                    else if ((c2 / c1) * 100 == 80)
                    {
                        System.out.println ("Very nice, 80% is a good mark!");
                    }
                    else if ((c2 / c1) * 100 == 70)
                    {
                        System.out.println ("70% isn't bad, but I think you can do better.");
                    }
                    else if ((c2 / c1) * 100 == 60)
                    {
                        System.out.println ("You should know Canada's provinces a little better then that.");
                    }
                    else if ((c2 / c1) * 100 == 50)
                    {
                        System.out.println ("You barely passed. You might want to read up on your provinces a bit more.");
                    }
                    else if ((c2 / c1) * 100 < 50)
                    {
                        System.out.println ("I'm sorry, but you failed.");
                    }
                    if ((c2 / c1) * 100 < 50)
                    {
                        System.out.println ("Because your mark is so low, I'm forcing you to do this again.");
                        System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                        continue;
                    }
                    else if ((c2 / c1) * 100 >= 50)
                    {
                        System.out.println ("Would you like to play again? Yes/No");
                        playagain = br.readLine ();
                        if (playagain.equalsIgnoreCase ("yes") || playagain.equalsIgnoreCase ("y"))
                        {
                            System.out.println ("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
                            continue;
                        }
                        else
                            break;
                    }
                }
            } //end while
        } //public statement
    } //class statement

  2. #2
    SecurityCop is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    Sorry, I forgot to mention, I'm using Ready to Program 1.7.1 which uses Java 1.4.2

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

    Default

    You may wish to simplify your code so that it's a lot smaller, still compiles and demonstrates your problem. I can't speak for all, but I know that many will not be willing to wade through that amount of code. Not only that, if you shrink your code down in an attempt to simplify the problem, often you see the solution yourself. A link that will help you in this simplification process can be found here: Short, Self Contained, Correct (Compilable), Example

    Much luck!

    edit: Also, in your demo program you'll want to use images via links to the web so that they are available to all, rather than use images local to your computer. This is also mentioned in the link above.
    Last edited by Fubarable; 11-27-2009 at 07:48 PM.

  4. #4
    SecurityCop is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    Alright, I'm still pretty new to this, so give me a minute to try and see what can be taken out.

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

    Default

    Quote Originally Posted by SecurityCop View Post
    Alright, I'm still pretty new to this, so give me a minute to try and see what can be taken out.
    Oh, don't worry -- take all the time you need. Just please have a look at the link above before you do this task as it will have important recommendations that will help us help you.

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

    Default

    Also, on glancing at your program, I don't really see true applet GUI code, but more of a command-line program code with a main method. Are you sure that this is a GUI program that you're creating here? It looks like it's trying to be both, like you're splicing together two completely different programs, one an applet and one a command-line program, and hoping and praying that they will mathemagically will work together. I'm afraid that that's not going to happen.
    Last edited by Fubarable; 11-27-2009 at 09:37 PM.

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

    Default

    OK, I looked a bit more and saw this:
    Java Code:
      public void main(String[] args, Graphics g) throws java.io.IOException {
    And I can see that I was right -- you are trying to splice two completely different types of programs together, and no, it won't work this way. You need to stop what you're doing here, take a breather, and then read the Sun tutorials on how to create GUI programs (including applets and non-applet GUIs) because the way you're attacking this will not work and will never work. Sorry to be blunt, but no one can fix this code for you as it's unfixable. Read the tutorials, read and study the sample programs and you'll see why.

    Also, you'll probably not want to do AWT / Applet coding but rather Swing coding (with JApplets and JFrames) as it is more powerful and flexible. Best of luck.

  8. #8
    SecurityCop is offline Member
    Join Date
    Nov 2009
    Posts
    4
    Rep Power
    0

    Default

    Ah I see, well thank you for telling me. I was trying everything possible, hoping that the image would come up in the applet and the program would come up in the line.
    As I said, I'm just starting out on Java. I barely have any idea of the rules and complexity it has. I have the grade 11 course this semester, grade 12 next semester, then going into University for game design next year, so hopefully by then, I switch to C and C++.
    Thank you again though.

Similar Threads

  1. HTML linking and java applets
    By Bomber_Will in forum Java Applets
    Replies: 4
    Last Post: 02-08-2009, 08:50 PM
  2. using java applets for dag & drop interface
    By frea in forum New To Java
    Replies: 0
    Last Post: 03-27-2008, 09:31 PM
  3. reading dir in java applets
    By willemjav in forum Java Applets
    Replies: 3
    Last Post: 02-07-2008, 01:36 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
  •