//************************************************************************************************** //Method: private letters GetLetters() //Purpose: gen rdm letters //Returns: newletters- rdm letters with rdm values //************************************************************************************************** private letters GetLetters() { letters newletters; // to be filled with rdm letters and returned to list char characterrs; // rdm leter in alphabet int speed; // rdm speed from 2-10 int xPos; // rdm x pos from 50-750 int yPos; // rdm y pos from 10-100 int count; // loop through letter list bool rdmletters; //flag to find unique letters Random rdm = new Random(); // randomizer do { // set true to loop for unique characters rdmletters = true; //generate rdm letters for a to z characterrs = (char)rdm.Next((int)'a', (int)'z'); //check list to see if a letter already has been generated for (count = 0; count < _lettersList.Count; count++) { //set false flag so anew letter can be generated if (_lettersList[count].words == characterrs) { rdmletters = false; } } } while (!rdmletters); // keep generating unique letters // generate rdm speed and letter start possition speed = rdm.Next(2, 11); xPos = rdm.Next(50, 751); yPos = rdm.Next(10, 101); // assign values and return them newletters = new letters() { words = characterrs, speed = speed, xPos = xPos, yPos = yPos }; return(newletters); }
public void getIncorrectGuessesTest() { letters target = new letters(); // TODO: Initialize to an appropriate value int expected = 0; // TODO: Initialize to an appropriate value int actual; actual = target.getIncorrectGuesses(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
public void updateTest() { string guessedLetters; letters target = new letters(); // TODO: Initialize to an appropriate value bool correctGuess = false; // TODO: Initialize to an appropriate value char input = 'a'; // TODO: Initialize to an appropriate value target.update(correctGuess, input); input = 'a'; // TODO: Initialize to an appropriate value target.update(correctGuess, input); input = 'b'; // TODO: Initialize to an appropriate value target.update(correctGuess, input); guessedLetters = target.getLettersUsed(); Assert.AreEqual(guessedLetters,"ab",true); }
public void lettersConstructorTest() { letters target = new letters(); Assert.Inconclusive("TODO: Implement code to verify target"); }
public void printTest() { letters target = new letters(); // TODO: Initialize to an appropriate value target.print(); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public void getLettersUsedTest() { letters target = new letters(); // TODO: Initialize to an appropriate value string expected = string.Empty; // TODO: Initialize to an appropriate value string actual; actual = target.getLettersUsed(); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
// // Method chooseLetter processes the choosen letter. The counter for correct // letters is decremented for every occurance of the letter. The counter for // wrong guesses is also processed. // private void chooseLetter(letters x) { DialogResult result; bool answeredCorrectly = false; int letterIndex = (int)x; letterPanel.Controls[letterIndex].Enabled = false; // // Search the slected word for the letter we are processing. // for (int idx = 0; idx < selectedWord.Length; idx++) { if (selectedWord[idx] == letterPanel.Controls[letterIndex].Text[0]) { // The Player has guessed correctly answerCnt--; answeredCorrectly = true; dashPanel.Controls[idx].Text = letterPanel.Controls[letterIndex].Text; } } if (answeredCorrectly == false) { // The Player has guessed wrong quessWrong(); } else if (answerCnt == 0) { // // The player has won! The player has won! // result = MessageBox.Show("You have won!!\n\nWay to Go!\n\nDo you want to play again?", "Big Winner", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (result == DialogResult.Yes) newGame(); else this.Close(); } }
void CreateButton(GameObject go, float x, float y, float sx, float sy, string name, int number) { int depth = 0;//NGUITools.CalculateNextDepth(go); go = NGUITools.AddChild(go); //go = Resources.Load("l") as GameObject; go.transform.localPosition = new Vector3(x, y, 0f); go.transform.localScale = new Vector3(sx, sy, 1f); go.name = "letter" + number.ToString(); letters bt = go.AddComponent <letters>(); //go.AddComponent<UIButtonScale>(); //go.AddComponent<UIButtonOffset>(); //UIButtonSound tp = go.AddComponent<UIButtonSound>(); _goButton = go; UISprite bg = NGUITools.AddWidget <UISprite>(go); bg.name = "Background"; bg.depth = depth; bg.type = UISprite.Type.Sliced; bg.atlas = _atlas; //bg.color = new Color(0.8f, 0.8f , 0.8f , 1f); bg.spriteName = "btn_8"; //bg.transform.localScale = new Vector3(sx/10f, sy/10f, 1f); // bg.MakePixelPerfect(); UILabel lbl = NGUITools.AddWidget <UILabel>(go); lbl.name = "lbl" + number.ToString(); GameObject lb = GameObject.Find("lbl" + number.ToString()); lb.transform.localPosition = new Vector3(0f, -5f, 0f); lbl.trueTypeFont = _font; lbl.fontSize = 60; if (PlayerPrefs.GetInt("o0") == number || PlayerPrefs.GetInt("o1") == number || PlayerPrefs.GetInt("o2") == number || PlayerPrefs.GetInt("o3") == number || PlayerPrefs.GetInt("o4") == number || PlayerPrefs.GetInt("o5") == number || PlayerPrefs.GetInt("o6") == number || PlayerPrefs.GetInt("o7") == number || PlayerPrefs.GetInt("o8") == number) { lbl.text = Main.word[number].ToString(); } lbl.MakePixelPerfect(); lb.transform.localScale = new Vector3(1, 1, 1f); lbl.text = Main.word[number].ToString().ToUpper(); lbl.color = new Color(0f, 0f, 0f, 1f); //lbl.effectStyle = UILabel.Effect.Outline; //lbl.effectColor = new Color(1f, 1f , 1f , 1f); bt.letter = Main.word[number].ToString().ToUpper(); bt.lbl = lbl; bt.num = number; // Add a collider NGUITools.AddWidgetCollider(go); //col.size = new Vector3(150, 150, 1); // Add the scripts // TweenPosition tp = go.AddComponent<TweenPosition>(); // tp.to = new Vector3(0, 200, 0); // tp.duration = 4f; // tp.Play(true); //Invoke("RemoveButton", 5f); }
static void Main(string[] args) { List <string> lines = new List <string>(); List <letters> letters = new List <Program.letters>(); char separator = ' '; try { using (StreamReader sr = new StreamReader("Test.txt")) { foreach (var lin in File.ReadLines("Test.txt")) { lines.Add(lin); } } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } string[,] tab = new string[lines.Count, 7]; for (int i = 0; i < lines.Count; i++) { string[] wordsInLine = lines[i].Split(separator); for (int j = 0; j < 7; j++) { tab[i, j] = wordsInLine[j]; } letters tmp = new letters(); tmp.name = wordsInLine[0]; tmp.value = 0; letters.Add(tmp); } for (int i = 0; i < letters.Count; i++) { for (int j = 0; j < letters.Count; j++) { if (i == j) { } else if (letters[i].name == letters[j].name) { Console.WriteLine(); letters.RemoveAt(j); j--; } } } for (int i = 0; i < letters.Count; i++) { Console.WriteLine(letters[i].name); } int max = 0; for (int i = 0; i < lines.Count; i++) { string[] wordsInLine = lines[i].Split(separator); for (int j = 0; j < letters.Count; j++) { if (letters[j].name == wordsInLine[4]) { letters tmp = letters[j]; if (wordsInLine[5] == "==") { int number = int.Parse(wordsInLine[6]); if (tmp.value == number) { letters tmpNext = new Program.letters(); int counter = 0; for (int k = 0; k < letters.Count; k++) { if (wordsInLine[0] == letters[k].name) { counter = k; tmpNext = letters[k]; break; } } if (wordsInLine[1] == "inc") { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value += firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } else { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value -= firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } } } else if (wordsInLine[5] == "!=") { int number = int.Parse(wordsInLine[6]); if (tmp.value != number) { letters tmpNext = new Program.letters(); int counter = 0; for (int k = 0; k < letters.Count; k++) { if (wordsInLine[0] == letters[k].name) { counter = k; tmpNext = letters[k]; break; } } if (wordsInLine[1] == "inc") { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value += firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } else { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value -= firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } } } else if (wordsInLine[5] == ">=") { int number = int.Parse(wordsInLine[6]); if (tmp.value >= number) { letters tmpNext = new Program.letters(); int counter = 0; for (int k = 0; k < letters.Count; k++) { if (wordsInLine[0] == letters[k].name) { counter = k; tmpNext = letters[k]; break; } } if (wordsInLine[1] == "inc") { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value += firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } else { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value -= firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } } } else if (wordsInLine[5] == ">") { int number = int.Parse(wordsInLine[6]); if (tmp.value > number) { letters tmpNext = new Program.letters(); int counter = 0; for (int k = 0; k < letters.Count; k++) { if (wordsInLine[0] == letters[k].name) { counter = k; tmpNext = letters[k]; break; } } if (wordsInLine[1] == "inc") { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value += firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } else { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value -= firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } } } else if (wordsInLine[5] == "<=") { int number = int.Parse(wordsInLine[6]); if (tmp.value <= number) { letters tmpNext = new Program.letters(); int counter = 0; for (int k = 0; k < letters.Count; k++) { if (wordsInLine[0] == letters[k].name) { counter = k; tmpNext = letters[k]; break; } } if (wordsInLine[1] == "inc") { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value += firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } else { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value -= firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } } } else if (wordsInLine[5] == "<") { int number = int.Parse(wordsInLine[6]); if (tmp.value < number) { letters tmpNext = new Program.letters(); int counter = 0; for (int k = 0; k < letters.Count; k++) { if (wordsInLine[0] == letters[k].name) { counter = k; tmpNext = letters[k]; break; } } if (wordsInLine[1] == "inc") { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value += firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } else { int firstNumber = int.Parse(wordsInLine[2]); tmpNext.value -= firstNumber; if (tmpNext.value >= max) { max = tmpNext.value; } letters[counter] = tmpNext; break; } } } } } } Console.WriteLine("w dowolnym momenci max to {0}", max); int maxOnEnding = 0; for (int i = 0; i < letters.Count; i++) { if (letters[i].value > maxOnEnding) { maxOnEnding = letters[i].value; } } Console.WriteLine("na koncu max to {0}", maxOnEnding); }