static void Main(string[] args) { QuestionAnswer myQA = new QuestionAnswer("What is 2+3?", 5); Console.WriteLine(myQA.getQuestion()); Console.WriteLine(myQA.getAnswer()); Console.ReadLine(); }
static void Main(string[] args) { String[] questionArray = new string[5]; int[] answerArray = new int[5]; int userAnswer; int score = 0; const int myAge = 22; string userAge; int ourAge; int intVal; string name = "Bob"; string favGame = "The Witcher 3"; var rand = new Random(); questionArray[0] = "What is 2+3?"; questionArray[1] = "What is 5+4?"; questionArray[2] = "What is 10+6?"; questionArray[3] = "What is 5+8?"; questionArray[4] = "What is 3+9?"; answerArray[0] = 5; answerArray[1] = 9; answerArray[2] = 16; answerArray[3] = 13; answerArray[4] = 12; Console.Write("What is your name?"); name = Console.ReadLine(); Console.Write("How old are you?"); userAge = Console.ReadLine(); intVal = Convert.ToInt32(userAge); ourAge = intVal + myAge; Console.Write("What is your favorite game?"); favGame = Console.ReadLine(); Console.WriteLine("Hello " + name + "!" + " You are " + userAge + " and your favorite game is " + favGame + "!"); Console.WriteLine("Our ages added together would be " + ourAge + "!"); Console.WriteLine("Wanna play a game?"); for (int i = 0; i < questionArray.Length; i++) { int randomOne = rand.Next(0, intVal); int randomTwo = rand.Next(0, intVal); int ans = randomOne + randomTwo; QuestionAnswer myQA = new QuestionAnswer(questionArray[i], answerArray[i]); Console.WriteLine(myQA.getQuestion()); userAnswer = Int32.Parse(Console.ReadLine()); if (userAnswer != myQA.getAnswer()) { i -= 1; score -= 1; Console.WriteLine("INCORRECT! Try again :)"); } else if (userAnswer == myQA.getAnswer()) { score += 1; Console.WriteLine("That is correct! The answer is " + myQA.getAnswer() + "!"); } else if (i == questionArray.Length) { Console.WriteLine("You have finished!"); } } Console.WriteLine("You have finished! You scored " + score + " out of 5"); /* * //prinmitive array * int[] myAnswerArray = { 3,5,7,11,13}; * * // * String[] myQuestionArray = new string[5]; * * for(int i = 0; i<myAnswerArray.Length; i++) * { * myAnswerArray[i] = i + 5; * } * for (int i = 0; i < myAnswerArray.Length; i++) * { * Console.WriteLine(myAnswerArray[i]); * } * * int sizeOfArray = Int32.Parse(Console.ReadLine()); * //myAnswerArray = new int[sizeOfArray]; * */ //creating new random object //class name variable name = instance of class /* * Random myRandom = new Random(); * int randomNumber = myRandom.Next(4, 10); * * * * if (randomNumber<7 && randomNumber>0) * { * Console.Write("You are less than seven and greater than zero"); * } * else if(randomNumber>6) * { * Console.Write("You are greater than 6"); * } * else * { * Console.Write("idk whats goin on dood"); * } * Console.Write("What is your name?"); * String name = Console.ReadLine(); * * Console.Write("What is your age?"); * int age = Int32.Parse(Console.ReadLine()); */ }
//Function that displays GUI void OnGUI() { if (GlobalFunctions.isLoading) { return; } if (canvas.activeInHierarchy) { return; //if the menu canvas is active, dont continue. } if (skin != null) { if (GUI.skin != skin) { GUI.skin = skin; // if the skin exists, set the gui skin to skin provided. } } if (!showQuestion && !isFinished) { if (_camera != null) //Change Camera based on slider value if the camera is not empty { _camera.transform.position = new Vector3(_camera.transform.position.x, _camera.transform.position.y, GUI.VerticalSlider(new Rect(50, 0, 150, Screen.height * 0.8f), _camera.transform.position.z, -50, -300)); } //code for enabling animation of puzzle piece during switching animate = GUI.Toggle(new Rect(Screen.width * 0.9f, 0, Screen.width * 0.1f, 50), animate, "Do animation"); //code for sort button if (GUI.Button(new Rect(Screen.width * 0.9f, Screen.height * 0.1f, Screen.width * 0.1f, Screen.height * 0.1f), "Sort(dev)")) { Fix(); //On click, fire fix function } if (GUI.Button(new Rect(Screen.width * 0.5f - Screen.width * 0.05f, Screen.height * 0, Screen.width * 0.1f, Screen.height * 0.1f), "Menu")) { //when menu button is clicked, set the menu canvas to true and play a sound canvas.SetActive(!canvas.activeInHierarchy); GlobalFunctions.PlayAudio("press"); } } if (showQuestion && !isFinished) { GUI.Label(new Rect(Screen.width * 0.2f, Screen.height * 0.3f, Screen.width * 0.6f, Screen.height * 0.2f), qa.getQuestion(qa.questionID)); input = GUI.TextField(new Rect(Screen.width * 0.2f, Screen.height * 0.6f, Screen.width * 0.6f, Screen.height * 0.1f), input); string temp = input.ToLower(); string answer = qa.answer.ToLower(); if (temp.Equals(answer)) { GlobalFunctions.PlayAudio("Team_Accept_1"); Save(); isFinished = true; gameStarted = false; } } if (isFinished) { GUI.Label(new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width, Screen.height * 0.7f), qa.trivia); if (GUI.Button(new Rect(0, Screen.height * 0.7f, bw, bh), "Menu")) { GlobalFunctions.PlayAudio("confirm"); GlobalFunctions.changeScene("menuscreen"); } //0629bayanDSLWiFi if (level <= 29) { if (GUI.Button(new Rect(Screen.width / 2 - bw / 2, Screen.height * 0.7f, bw, bh), "Next")) { NextLevel(); } } else if (level == 30) { if (GUI.Button(new Rect(Screen.width / 2 - (bw * 3) / 2, Screen.height * 0.7f, bw * 3, bh), "Game Mode Cleared")) { GlobalFunctions.PlayAudio("confirm"); GlobalFunctions.changeScene("rounds-hard"); } } if (GUI.Button(new Rect(Screen.width - bw, Screen.height * 0.7f, bw, bh), "Rounds")) { GlobalFunctions.PlayAudio("confirm"); GlobalFunctions.changeScene("rounds-hard"); } } }