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

