Jump to content

dazzahatty

Members
  • Posts

    2
  • Joined

  • Last visited

Everything posted by dazzahatty

  1. using System; using System.IO; namespace WordsearchACW { class Program { //hardCode is the name of the board. This method is using hardCode to display the board and produce the numbers at the sides of the columns and rows. //This block of code is also used to change the colour of the rows and column numbers to yellow. static void ShowBoard(string[,] hardCode) { Console.Write(" "); for (int column = 0; column < hardCode.GetLength(0); column++) { Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(" " + column); Console.ResetColor(); } Console.WriteLine(""); for (int rows = 0; rows < hardCode.GetLength(1); rows++) { Console.ForegroundColor = ConsoleColor.Yellow; Console.Write(rows); Console.ResetColor(); for (int column = 0; column < hardCode.GetLength(0); column++) { Console.Write(" " + hardCode[column, rows]); } Console.WriteLine(""); } } public struct WordsCoords { public int startRow; public int endRow; public int startColumn; public int endColumn; } // This method sends a prompt to the user which then returns a value within a range from the given prompt static int GetNumber(string Message, int Min, int Max) { int result; do { Console.WriteLine(Message + Min + " and " + Max + " inclusive."); result = int.Parse(Console.ReadLine()); } while (result < Min || result > Max); return result; } static void Main(string[] args) { string[,] hardCode = new string[0, 0]; //Creating a menu to choose the variois different options, produce a hardcoded wordsearch from File01 and read in the other 6 files. Console.WriteLine("Wordsearch ACW"); Console.WriteLine(); Console.WriteLine("Select an option: \n1. Use default wordsearch \n2. Load wordsearch from file"); Console.WriteLine(); Console.WriteLine("Enter a number from 1 to 2 inclusive"); int input = int.Parse(Console.ReadLine()); Console.Clear(); if (input == 1) { hardCode = new string[9, 5]; // Using the random generator to generate a random letter in an 8x4 grid Random rlg = new Random(); for (int letter = 0; letter < hardCode.GetLength(1); letter++) { for (int nextLetter = 0; nextLetter < hardCode.GetLength(0); nextLetter++) { hardCode[nextLetter, letter] = Convert.ToString((char)rlg.Next('a', 'z')); } } // This code is treating the strings algorithm and virus as first ints and then chars and manipulating those specific co-ordinates on the grid to produce the words. string wordOne = "algorithm"; for (int i = 0; i < 9; i++) { hardCode[i, 1] = wordOne[i].ToString(); } string wordTwo = "virus"; for (int j = 1; j < 6; j++) { hardCode[j, 4] = wordTwo[5 - j].ToString(); } ShowBoard(hardCode); Console.WriteLine("\nWords To Find\nalgorithm\nvirus\n"); do { int startColumn = GetNumber("Please enter start column\nEnter a number between ", 0, 8); int startRow = GetNumber("Please enter start row\nEnter a number between ", 0, 4); int endColumn = GetNumber("Please enter end column\nEnter a number between ", 0, 8); int endRow = GetNumber("Please enter end row\nEnter a number between ", 0, 4); // Make start column, start row, end column, end row = the values on the board to find algorithm and virus if (startColumn == 0 && startRow == 1 && endColumn == 8 && endRow == 1) { Console.WriteLine("Congratulations you found algorithm!!!!"); } else if (startColumn == 5 && startRow == 4 && endColumn == 1 && endRow == 4) { Console.WriteLine("Congratulations you found virus!!!!"); break; } } while (true); Console.Clear(); Console.WriteLine("Congratulations you have found all of the words\n"); } else if (input == 2) // This code is reading in the files { string[] files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*.wrd"); for (int i = 0; i < files.Length; i++) { Console.WriteLine((i + 1) + ". " + files[i]); } int fileNumber = GetNumber("Please enter a number between ", 1, 7); } Console.WriteLine("Press any key to exit."); Console.ReadKey(); } } } Thank you for your response friend. I'll be sure to check out udemy. I really appreciate this. Thank you so very much.
  2. Hi, I'm new to the forum and just seeking advice with programming in general. I've studied computer science for one year and I don't feel I understand enough about coding/programming. I'm really concerned about this as I have a programming assignment that's due the start of August and I've made very little progress with it. The other modules that don't involve as much coding and programming I've been absolutely fine with. It's just the programming assignments. I cannot build programs, I really don't know why. My brain just cannot understand it and as a computer science student, that's a massive problem. Can anybody please help? Thank you.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.