What's new

Closed The name 'global' does not exist in the current context (cs0103)

Status
Not open for further replies.
D

Deleted member 1356611

Guest
Mga parekoy, tulungan niyo ako kung paano, ififix etong problema ko, wala daw makitang "Global" sa Program ko:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace ConsoleApplication1
{
class WWTBAM
{
static void Main(string[] args)
{
Console.WriteLine("Who Wants to Be a Millionaire\n\n\n");
Console.WriteLine("Main Menu");
SelectQuestion();
Console.Write("Press any key to quit");
Console.Read();
}

public static void SelectQuestion()
{
Globals.count = Globals.count + 1;
Random Questionselect = new Random();
int QuestionNumber = Questionselect.Next(1, 11);
Globals.questionNumber++;
if (Globals.count >= 2)
{
Globals.money = Globals.money * 2;
}
if (Globals.count == 1)
{
Globals.money = 1000;
}
Console.WriteLine("");
Console.WriteLine("You have earned: $" + Globals.money);
Console.WriteLine(Globals.count);
Console.ReadLine();
switch (QuestionNumber)
{
case 1:
Console.Clear();
Question1();
break;
case 2:
Console.Clear();
Question2();
break;
case 3:
Console.Clear();
Question3();
break;
case 4:
Console.Clear();
Question4();
break;
case 5:
Console.Clear();
Question5();
break;
case 6:
Console.Clear();
Question6();
break;
case 7:
Console.Clear();
Question7();
break;
case 8:
Console.Clear();
Question8();
break;
case 9:
Console.Clear();
Question9();
break;
case 10:
Console.Clear();
Question10();
break;
case 11:
Console.Clear();
Question11();
break;
}
}

public static void Question1()
{
while (Globals.Selected1 == false)
{
Console.WriteLine("Canada's most densely populated province is:");
Console.WriteLine("a: Ontario");
Console.WriteLine("b: Quebec");
Console.WriteLine("c: Saskatchewan");
Console.WriteLine("d: Prince Edward Island");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Correct");
Globals.Selected1 = true;
SelectQuestion();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question1();
break;
}
}
SelectQuestion();
}

public static void Question2()
{
while (Globals.Selected2 == false)
{
Console.WriteLine("Whom does the governor general of Canada represent at the federal level?");
Console.WriteLine("a: The Prime Minister");
Console.WriteLine("b: The Queen of Canada");
Console.WriteLine("c: The Chief of Staff");
Console.WriteLine("d: The Deputy Minister");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Correct");
Globals.Selected2 = true;
SelectQuestion();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question2();
break;
}
}
SelectQuestion();
}

public static void Question3()
{
while (Globals.Selected3 == false)
{
Console.WriteLine("Where are the highest tides in the world?");
Console.WriteLine("a: Hudson's Bay, between Ontario, Quebec, Manitoba, and Nunavut");
Console.WriteLine("b: The Bay of Fundy, between Nova Scotia and New Brunswick");
Console.WriteLine("c: James Bay, between Ontario and Quebec");
Console.WriteLine("d: Cowichan Bay, British Colimbia");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Correct");
Globals.Selected3 = true;
SelectQuestion();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question3();
break;
}
}
SelectQuestion();
}

public static void Question4()
{
while (Globals.Selected4 == false)
{
Console.WriteLine("What is the only officially bilingual province in Canada?");
Console.WriteLine("a: Ontario");
Console.WriteLine("b: Quebec");
Console.WriteLine("c: Alberta");
Console.WriteLine("d: New Brunswick");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Correct");
Globals.Selected4 = true;
SelectQuestion();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question4();
break;
}
}
SelectQuestion();
}

public static void Question5()
{
while (Globals.Selected5 == false)
{
Console.WriteLine("What famous sea creature in the Okanagan Lake of British Columbia was called");
Console.WriteLine("N'ha-a-itk by local Aboriginal tribes and is considered" + "Canada's Loch Ness Monster" + "?");
Console.WriteLine("a: Manopogo");
Console.WriteLine("b: Okanaganaka");
Console.WriteLine("c: Ogopogo");
Console.WriteLine("d: Champ");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Correct");
Globals.Selected5 = true;
SelectQuestion();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question5();
break;
}
}
SelectQuestion();
}

public static void Question6()
{
while (Globals.Selected6 == false)
{
Console.WriteLine("Who was the first woman to serve as governor general of Canada?");
Console.WriteLine("a: Jeanne Sauvé");
Console.WriteLine("b: Jean Augustine");
Console.WriteLine("c: Adrienne Clarkson");
Console.WriteLine("d: Michaëlle Jean");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Correct");
Globals.Selected6 = true;
SelectQuestion();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question6();
break;
}
}
SelectQuestion();
}

public static void Question7()
{
while (Globals.Selected7 == false)
{
Console.WriteLine("Who is Canada's Head of State?");
Console.WriteLine("a: Her Majesty the Queen of Canada (Elizabeth II) ");
Console.WriteLine("b: The Prime Minister");
Console.WriteLine("c: The Governor General");
Console.WriteLine("d: None of the above");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Correct");
Globals.Selected7 = true;
SelectQuestion();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question7();
break;
}
}
SelectQuestion();
}

public static void Question8()//Micmac
{
while (Globals.Selected8 == false)
{
Console.WriteLine("The Canadian Constitution officially recognizes which of the three main");
Console.WriteLine("categories of Aboriginal peoples in Canada?");
Console.WriteLine("a: First Nations, Inuits, Métis");
Console.WriteLine("b: Cree, Iroqouis, Miqmac");
Console.WriteLine("c: Inuit, Indian, Métis");
Console.WriteLine("d: Métis. Ojibwa, Iroquois");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Correct");
Globals.Selected8 = true;
SelectQuestion();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question8();
break;
}
}
SelectQuestion();
}

public static void Question9()
{
while (Globals.Selected9 == false)
{
Console.WriteLine("In descending order, name the three largest cities in Canada:");
Console.WriteLine("a: Toronto, Calgary, Vancouver");
Console.WriteLine("b: Toronto, Montreal, Vancouver");
Console.WriteLine("c: Calgary, Vancouver, Ottawa");
Console.WriteLine("d: Edmonton, Toronto, Vancouver");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Correct");
Globals.Selected9 = true;
SelectQuestion();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question9();
break;
}
}
SelectQuestion();
}

public static void Question10()
{
while (Globals.Selected10 == false)
{
Console.WriteLine("The efforts of women to achieve the right to vote is known as the women's");
Console.WriteLine("suffrage movement. Its founder in Canada was Dr. Emily Stowe, the first");
Console.WriteLine("Canadian woman to practise medicine in Canada. Thanks to her efforts,");
Console.WriteLine("women received the right to vote in 1916 in which province?");
Console.WriteLine("a: Ontario");
Console.WriteLine("b: Quebec");
Console.WriteLine("c: Manitoba");
Console.WriteLine("d: Prince Edward Island");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Wrong");
EndGame();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Correct");
Globals.Selected10 = true;
SelectQuestion();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question10();
break;
}
}
SelectQuestion();
}

public static void Question11()
{
while (Globals.Selected11 == false)
{
Console.WriteLine("Some Black Loyalists, from Nova Scotia, helped found _______ a new British Colony for freed slaves, in 1792.");
Console.WriteLine("a: Freetown, Sierra Leone (West Africa)");
Console.WriteLine("b: Johannesburg, South Africa");
Console.WriteLine("c: Saskatchewan");
Console.WriteLine("d: Harare, Zimbabwe");
string inptY = Console.ReadLine();
switch (inptY)
{
case "a":
Console.WriteLine("Correct");
Globals.Selected11 = true;
SelectQuestion();
break;
case "b":
Console.WriteLine("Wrong");
EndGame();
break;
case "c":
Console.WriteLine("Wrong");
EndGame();
break;
case "d":
Console.WriteLine("Wrong");
EndGame();
break;
default:
Console.Clear();
Console.WriteLine("Make sure you're saying a, b, c or d");
Question11();
break;
}
}
SelectQuestion();
}

public static void EndGame()
{
string playAgainResponse;

if (Globals.money == 1000000)
{
Console.WriteLine("Congratulaitons!!!!!!!!");
Console.WriteLine("You have won $" + Globals.money + "!!!!!");
Console.WriteLine("Play Again ? Y/N");
playAgainResponse = Console.ReadLine();
switch (playAgainResponse)
{
case "Y":
Main(null);
break;
case "N":
Console.WriteLine("Press any key to quit");
Console.Read();
break;
default:
Console.WriteLine("Make sure you are entering Y or N");
break;
}
}
else
{
Console.WriteLine("Nice try. Maybe you'll get it next time.");
Console.WriteLine("You are walking away with: $" + Globals.money);
Console.WriteLine("Play Again ? Y/N");
playAgainResponse = Console.ReadLine();
switch (playAgainResponse)
{
case "Y":
Main(null);
break;
case "N":
Console.WriteLine("Press any key to quit");
Console.Read();
break;
default:
Console.WriteLine("Make sure you are entering Y or N");
break;
}
}
}

/* static void Music()
{
Note[] Intro =
{

}
} */
}
 
base on your code..

add this

Code:
public static class Globals
        {           
            public static bool Selected10 { get; internal set; }
            public static bool Selected2 { get; internal set; }
            public static bool Selected3 { get; internal set; }
            public static bool Selected4 { get; internal set; }
            public static bool Selected5 { get; internal set; }
            public static bool Selected6 { get; internal set; }
            public static bool Selected7 { get; internal set; }
            public static bool Selected8 { get; internal set; }
            public static bool Selected9 { get; internal set; }
            public static int money { get; set; }
            public static bool Selected11 { get; set; }
            public static bool Selected1 { get; internal set; }
            public static int count { get; internal set; }
            public static int questionNumber { get; internal set; }
        }
 
Status
Not open for further replies.
Back
Top