예제 #1
0
        static void Main(string[] args)
        {
            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words
            RoverList list = new RoverList();

            list.Add("Hello");
            list.Add("World");
            list.Add("It's");
            list.Add("nice");
            list.Add("to");
            list.Add("meet");
            list.Add("you");

            list.ListNodes();

            // TODO:  Print out the list

            // TODO:  Remove every 3rd word
            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list

            // TODO:  Clear the list
            // TODO:  Print out the list
        }
예제 #2
0
        static void Main(string[] args)
        {
            RoverList <string> list = new RoverList <string>();

            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words

            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list

            // TODO:  Clear the list
            // TODO:  Print out the list
        }
예제 #3
0
        public static void Main(String[] args)
        {
            List <string> genreList = new List <string>()
            {
                "horror", "comedy", "romance",
                "drama", "thriller", "family",
                "war", "sci-fi", "history",
                "action", "crime", "adventure",
                "mystery", "animation", "sports",
                "documentary"
            };


            RoverList list = new RoverList();

            foreach (String s in genreList)
            {
                list.Add(s);
            }
            Console.WriteLine(list.Count);
            list.ListNodes();

            // TODO:  Print out the list

            // TODO:  Remove every 3rd word
            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list

            // TODO:  Clear the list
            // TODO:  Print out the list
        }
예제 #4
0
        static void Main(string[] args)
        {
            RoverList <string> list = new RoverList <string>();

            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words


            string[] words = "zero one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen".Split(' ');
            foreach (string word in words)
            {
                list.Add(word);
            }

            /*list.Add("another");
             * list.Add("yetAnother");
             * list.Add(3,"before");*/


            // TODO:  Print out the list

            list.ListNodes();

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list

            while (true)
            {
                string word = Console.ReadLine();
                if (word == "done")
                {
                    break;
                }
                list.Add(word);
            }


            list.ListNodes();

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            while (true)
            {
                string word = Console.ReadLine();
                if (word == "done")
                {
                    break;
                }
                list.Add(0, word);
            }


            list.ListNodes();

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list

            for (int n = 1; true; n++)
            {
                if (list.RemoveAt(n) == false)
                {
                    break;
                }
            }


            list.ListNodes();

            // TODO:  Clear the list
            // TODO:  Print out the list

            while (true)
            {
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            RoverList List  = new RoverList();
            string    input = "";
            string    check;
            int       pos;

            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words\
            List.Add("1");
            List.Add("2");
            List.Add("3");
            List.Add("4");
            List.Add("5");
            List.Add("6");
            List.Add("7");
            List.Add("8");
            List.Add("9");
            List.Add("10");
            List.Add("11");
            List.Add("12");
            List.Add("13");
            List.Add("14");
            List.Add("15");
            List.Add("16");

            // TODO:  Print out the list
            List.ListNodes();
            Console.WriteLine("");

            // TODO:  Remove every 3rd word
            // TODO:  Print out the list

            for (int i = 2; i < List.Count; i += 2)
            {
                List.RemoveAt(i);
            }

            List.ListNodes();
            Console.WriteLine("");

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list
            Console.WriteLine("Input words into the list(type \"done\" when finished):");
            while (input != "done")
            {
                input = Console.ReadLine();
                if (input != "done")
                {
                    List.Add(input);
                }
            }
            List.ListNodes();
            Console.WriteLine("");
            input = "";
            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            Console.WriteLine("Input words into the top of the list(type \"done\" when finished):");
            while (input != "done")
            {
                input = Console.ReadLine();
                if (input != "done")
                {
                    List.Add(0, input);
                }
            }
            List.ListNodes();
            Console.WriteLine("");

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list
            pos = List.Count - 1;
            while (pos >= 0)
            {
                check = List.ElementAt(pos).Data.ToString();
                if (check.Length % 2 != 0)
                {
                    List.RemoveAt(pos);
                }
                pos--;
            }

            List.ListNodes();
            Console.WriteLine("");

            // TODO:  Clear the list
            // TODO:  Print out the list
            List.Clear();
            List.ListNodes();
        }
예제 #6
0
        static void Main(string[] args)
        {
            // TODO:  Implement the RoverList class
            RoverList list = new RoverList();

            list.Add(null);
            // TODO:  Create a RoverList and then fill it with 16 words
            list.Add("A");         //
            list.Add("To");
            list.Add("Fad");       //

            list.Add("Quaff");     //
            list.Add("Mental");
            list.Add("Pyramid");   //
            list.Add("Enamored");
            list.Add("Planetary"); //
            list.Add("Beleagured");
            list.Add("Candy");     //
            list.Add("Candor");
            list.Add("Cadence");   //
            list.Add("Seratonin"); //
            list.Add("Implementation");
            list.Add(3, "Fungi");  //
            list.Add(6, "Abdicate");

            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Remove every 3rd word

            /*for (int i = 0; i<list.Count; i++)
             * {
             *  if ((i+1) %3==0)
             *  {
             *      list.RemoveAt(i);
             *  }
             *
             * }*/
            list.RemoveAt(5);
            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            bool cont = true;

            while (cont == true)
            {
                string userInput = Console.ReadLine();
                if (userInput.Equals("done"))
                {
                    break;
                }
                list.Add(userInput);
            }
            // TODO:  Print out the list
            list.ListNodes();

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            cont = true;
            while (cont == true)
            {
                string inpt = Console.ReadLine();

                if (inpt.Equals("done"))
                {
                    break;
                }
                list.Add(0, inpt);
            }
            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Remove every word with an odd length
            for (int i = 1; i < list.Count + 1; i++)
            {
                string great = (string)list.ElementAt(i).Data;
                int    len   = great.Length;
                if (len % 2 != 0)
                {
                    list.RemoveAt(i);
                    i--;
                }
            }
            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Clear the list
            list.Clear();
            // TODO:  Print out the list

            list.ListNodes();
        }
예제 #7
0
        static void Main(string[] args)
        {
            RoverList list  = new RoverList();
            String    input = "";
            int       b     = 0;
            int       c     = 0;

            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words
            list.Add("hello");
            list.Add("world");
            list.Add("alex");
            list.Add("is");
            list.Add("a");
            list.Add("borneo");
            list.Add("and");
            list.Add("wait");
            list.Add("frieza");
            list.Add("is");
            list.Add("cheating");
            list.Add("my");
            list.Add("name");
            list.Add("be");
            list.Add("jacco");
            list.Add("guys");
            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Remove every 3rd word
            list.RemoveAt(2);
            list.RemoveAt(4);
            list.RemoveAt(6);
            list.RemoveAt(8);
            list.RemoveAt(10);
            // TODO:  Print out the list
            Console.WriteLine("");
            list.ListNodes();
            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"

            Console.WriteLine();
            Console.WriteLine("Type words to add to the list. Write done when done.");
            while (input != "done")
            {
                input = Console.ReadLine();
                list.Add(input);
            }

            // TODO:  Print out the list
            list.ListNodes();
            input = "";
            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            Console.WriteLine("");
            Console.WriteLine("Type words to add to the front of the list. Write done when done.");
            while (input != "done")
            {
                input = Console.ReadLine();
                list.Add(0, input);
            }
            // TODO:  Print out the list
            Console.WriteLine("");
            list.ListNodes();
            // TODO:  Remove every word with an odd length
            while (list.ElementAt(b) != null)
            {
                c = (((list.ElementAt(b)).Data).ToString()).Length;
                Console.WriteLine(c);
                if (c % 2 != 0)
                {
                    list.RemoveAt(b);
                }
                b++;
            }
            // TODO:  Print out the list
            Console.WriteLine("");
            list.ListNodes();
            // TODO:  Clear the list
            // TODO:  Print out the list
        }
예제 #8
0
파일: Program.cs 프로젝트: IAISA/RoverList
        static void Main(string[] args)
        {
            RoverList <string> list = new RoverList <string>();

            list.Add("studying");
            list.Add("stressed");
            list.Add("city");
            list.Add("birthday");
            list.Add("school");
            list.Add("work");
            list.Add("basketball");
            list.Add("trampoline");
            list.Add("pizza");
            list.Add("milkshake");
            list.Add("homework");
            list.Add("research");
            list.Add("calculus");
            list.Add("summer");
            list.Add("college");
            list.Add("coding");

            list.ListNodes();

            Console.WriteLine("Please enter some words:");
            while (true)
            {
                Console.Write("> ");

                string line = Console.ReadLine();
                if (line == "done")
                {
                    break;
                }

                list.Add(line);
            }
            Console.WriteLine("");

            list.ListNodes();

            Console.WriteLine("");
            Console.WriteLine("Please enter some more words:");
            while (true)
            {
                Console.Write("> ");

                string line = Console.ReadLine();
                if (line == "done")
                {
                    break;
                }

                list.Add(0, line);
            }
            Console.WriteLine("");

            list.ListNodes();

            Console.WriteLine("");
            Console.WriteLine("Now I will remove all odd words");
            Console.WriteLine("");

            int count = list.Count - 1;

            while (count >= 0)
            {
                var word = list.ElementAt(count);

                if (word.Length % 2 != 0)
                {
                    list.RemoveAt(count);
                }
                count--;
            }

            Console.WriteLine("");
            list.ListNodes();

            Console.WriteLine("");
            Console.WriteLine("Now I will clear the list");

            list.Clear();

            list.ListNodes();

            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words

            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list

            // TODO:  Clear the list
            // TODO:  Print out the list
        }
예제 #9
0
        static void Main(string[] args)
        {
            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words

            RoverList rList = new RoverList();

            rList.Add("Gordon");
            rList.Add("Ramsay");
            rList.Add("Lamb Sauce");
            rList.Add("Eric Harris");
            rList.Add("Dylan Klebold");
            rList.Add("Klabundasaurus");
            rList.Add("idubbbz");
            rList.Add("maxmoefoe");
            rList.Add("Tank zos");
            rList.Add("Nofriendo Switch");
            rList.Add("Big Water");
            rList.Add("Gabe Newell");
            rList.Add("Harrible");
            rList.Add("Canada");
            rList.Add("CS1.6, CS1.6");
            rList.Add("Z9Z9Z9Z9Z9");
            // TODO:  Print out the list
            rList.ListNodes();

            // TODO:  Remove every 3rd word
            for (int i = 2; i < rList.Count; i += 3)
            {
                rList.RemoveAt(i);
            }

            Console.WriteLine();
            // TODO:  Print out the list
            rList.ListNodes();

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list
            String input = "";

            while (input != "done")
            {
                Console.Write("Enter any word then press enter, (enter 'done' to stop adding word): ");
                input = Console.ReadLine();

                if (input != "done")
                {
                    rList.Add(input);
                }
            }


            Console.WriteLine();

            rList.ListNodes();

            Console.WriteLine();

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            input = "";
            while (input != "done")
            {
                Console.Write("Enter any word then press enter, (enter 'done' to stop adding word): ");
                input = Console.ReadLine();

                if (input != "done")
                {
                    rList.Add(0, input);
                }
            }

            rList.ListNodes();

            Console.WriteLine();

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list
            for (int i = 0; i < rList.Count; i++)
            {
                if (rList.ElementAt(i).Data.ToString().Length % 2 != 0)
                {
                    rList.RemoveAt(i);
                    i--;
                }
            }
            rList.ListNodes();
            Console.WriteLine();

            // TODO:  Clear the list
            // TODO:  Print out the list

            rList.Clear();
            rList.ListNodes();
        }
예제 #10
0
        static void Main(string[] args)
        {
            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words
            RoverList list = new RoverList();

            list.Add("odd");
            list.Add("even");
            list.Add("odd");
            list.Add("even");
            list.Add("odd");
            list.Add("even");
            list.Add("odd");
            list.Add("even");
            list.Add("odd");
            list.Add("even");
            list.Add("odd");
            list.Add("even");
            list.Add("odd");
            list.Add("even");
            list.Add("odd");
            list.Add("even");



            //  TODO:  Print out the list
            list.ListNodes();



            // TODO:  Remove every 3rd word
            for (int i = 2; i < list.Count; i = i + 2)
            {
                list.RemoveAt(i);
            }

            // TODO:  Print out the list
            Console.WriteLine("\n");
            list.ListNodes();


            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            Console.WriteLine("\n Add words to the list");
            bool   done = false;
            String word;

            while (done == false)
            {
                word = Console.ReadLine();
                if (word == "done")
                {
                    done = true;
                }
                else
                {
                    list.Add(word);
                }
            }


            // TODO:  Print out the list
            Console.WriteLine("\n");
            list.ListNodes();


            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            Console.WriteLine("\n enter words to put in the front");

            while (true)
            {
                String newNode = Console.ReadLine();
                if (newNode == "done")
                {
                    break;
                }
                list.Add(newNode);
            }

            // TODO:  Print out the list
            Console.WriteLine("\n **********");
            list.ListNodes();

            /*/TODO:  Remove every word with an odd length
             * String thing = list.ElementAt(3).Data.ToString();/*/
            Console.WriteLine();
            // list.RemoveAt(0);
            // list.ListNodes();

            String words;

            for (int i = 0; i < list.Count; i++)
            {
                words = list.ElementAt(i).Data.ToString();

                if (words.Length % 2 != 0 || words.Length == 1)
                {
                    list.RemoveAt(i);

                    Console.WriteLine("*" + words + "*");

                    if (i == 0)
                    {
                        i = 0;
                    }
                    else
                    {
                        i--;
                    }
                }

                Console.WriteLine("\n" + words + "\n");
            }


            // TODO:  Print out the list

            list.ListNodes();

            // TODO:  Clear the list

            list.Clear();


            // TODO:  Print out the list
            Console.WriteLine("\n");
            list.ListNodes();
        }
예제 #11
0
        static void Main(string[] args)
        {
            // TODO:  Implement the RoverList class
            RoverList poop = new RoverList();

            // TODO:  Create a RoverList and then fill it with 16 words



            poop.Add("Hey");
            poop.Add("Now");
            poop.Add("You're"); //
            poop.Add("An");     //2
            poop.Add("All");
            poop.Add("Star");   //
            poop.Add("Get");    //2
            poop.Add("Your");
            poop.Add("Game");   //
            poop.Add("On");     //2
            poop.Add("Go");
            poop.Add("Play");   //
            poop.Add("I");      //2
            poop.Add("Want");
            poop.Add("To");     //
            poop.Add("Die");    //2

            // TODO:  Print out the list

            poop.ListNodes();
            Console.WriteLine("-----------------------------------");
            // TODO:  Remove every 3rd word
            for (int i = 2; i < poop.Count; i = i + 2)
            {
                poop.RemoveAt(i);
            }
            // TODO:  Print out the list
            poop.ListNodes();
            Console.WriteLine("-----------------------------------");

            // TODO:  Print out the list
            poop.ListNodes();
            Console.WriteLine("-----------------------------------");
            // TODO:  Remove every 3rd word
            for (int i = 2; i < poop.Count; i = i + 2)
            {
                poop.RemoveAt(i);
            }
            // TODO:  Print out the list
            poop.ListNodes();
            Console.WriteLine("-----------------------------------");
            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"

            Console.WriteLine("FEED ME WORDS ");


            while (true)
            {
                String newNode = Console.ReadLine();

                if (newNode == "done")
                {
                    break;
                }

                poop.Add(newNode);
            }
            // TODO:  Print out the list

            Console.WriteLine("-----------------------------------");
            poop.ListNodes();
            Console.WriteLine("-----------------------------------");
            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            Console.WriteLine("FEED ME MORE WORDS ");
            while (true)
            {
                object newStuff = Console.ReadLine();

                if (newStuff.ToString() == "done")
                {
                    break;
                }

                poop.Add(0, newStuff);
            }
            // TODO:  Print out the list
            Console.WriteLine("-----------------------------------");
            poop.ListNodes();
            // TODO:  Remove every word with an odd length
            for (int i = 0; i < poop.Count; i++)
            {
                if (poop.ElementAt(i).Data.ToString().Length % 2 != 0 || poop.ElementAt(i).Data.ToString().Length == 1)
                {
                    poop.RemoveAt(i);
                }
            }
            poop.RemoveAt(0);
            // TODO:  Print out the list
            Console.WriteLine("-----------------------------------");
            poop.ListNodes();
            // TODO:  Clear the list
            poop.Clear();
            // TODO:  Print out the list
            Console.WriteLine("-----------------------------------");
            poop.ListNodes();
            Console.WriteLine("-----------------------------------");
        }
예제 #12
0
        static void Main(string[] args)
        {
            RoverList <string> list = new RoverList <string>();

            list.Add("jelly");
            list.Add("psychology");
            list.Add("Boston");
            list.Add("GoogleSlides");
            list.Add("birthday");
            list.Add("toothbrush");
            list.Add("school");
            list.Add("summer");
            list.Add("program");
            list.Add("books");
            list.Add("probability");
            list.Add("history");
            list.Add("COVID-19");
            list.Add("hair");
            list.Add("glasses");
            list.Add("computer");

            list.ListNodes();

            Console.WriteLine("Please enter some words:");
            while (true)
            {
                Console.Write("> ");

                string line = Console.ReadLine();
                if (line == "done")
                {
                    break;
                }

                list.Add(line);
            }
            Console.WriteLine("");

            list.ListNodes();

            Console.WriteLine("");
            Console.WriteLine("Please enter some more words:");
            while (true)
            {
                Console.Write("> ");

                string line = Console.ReadLine();
                if (line == "done")
                {
                    break;
                }

                list.Add(0, line);
            }
            Console.WriteLine("");

            list.ListNodes();

            Console.WriteLine("");
            Console.WriteLine("Now I will remove all odd words");
            Console.WriteLine("");


            int count = list.Count - 1;

            while (count >= 0)
            {
                var word = list.ElementAt(count);

                if (word.Length % 2 != 0)
                {
                    list.RemoveAt(count);
                }
                count--;
            }

            Console.WriteLine("");
            list.ListNodes();

            Console.WriteLine("");
            Console.WriteLine("Now I will clear the list");

            list.Clear();

            list.ListNodes();
            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words

            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list

            // TODO:  Clear the list
            // TODO:  Print out the list
        }
예제 #13
0
        static void Main(string[] args)
        {
            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words
            RoverList myList = new RoverList();

            myList.Add("apple");
            myList.Add("bottom");
            myList.Add("jeans");
            myList.Add("boots");
            myList.Add("with");
            myList.Add("the");
            myList.Add("fur");
            myList.Add("she");
            myList.Add("hit");
            myList.Add("floor");
            myList.Add("next");
            myList.Add("thing");
            myList.Add("you");
            myList.Add("know");
            myList.Add("shawty");
            myList.Add("low");

            // TODO:  Print out the list
            Console.WriteLine("All items:");
            myList.ListNodes();

            // TODO:  Remove every 3rd word
            // TODO:  Print out the list
            int count = myList.Count;

            for (int i = 2; i < count; i += 2)
            {
                myList.RemoveAt(i);
            }
            Console.WriteLine("Every third node removed:");
            myList.ListNodes();

            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            // TODO:  Print out the list
            while (true)
            {
                Console.Write("Enter words to be added to the end of the list (type 'done' when finished): ");
                String input = Console.ReadLine();
                if (input == "done")
                {
                    break;
                }
                else
                {
                    myList.Add(input);
                }
            }
            Console.WriteLine("Words added to the end of the list: ");
            myList.ListNodes();

            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            // TODO:  Print out the list
            while (true)
            {
                Console.Write("Enter words to be added to the beginning of the list (type 'done' when finished): ");
                String input = Console.ReadLine();
                if (input == "done")
                {
                    break;
                }
                else
                {
                    myList.Add(0, input);
                }
            }
            Console.WriteLine("Words added to the beginning of the list: ");
            myList.ListNodes();

            // TODO:  Remove every word with an odd length
            // TODO:  Print out the list
            for (int i = 0; i < myList.Count; i++)
            {
                if (myList.ElementAt(i).Data.ToString().Length % 2 == 1)
                {
                    myList.RemoveAt(i);
                    i--;
                }
            }
            Console.WriteLine("Every odd length word removed:");
            myList.ListNodes();

            // TODO:  Clear the list
            // TODO:  Print out the list
            myList.Clear();
            Console.WriteLine("List cleared: ");
            myList.ListNodes();

            Console.ReadLine();
        }
예제 #14
0
        static void Main(string[] args)
        {
            //Create a RoverList and then fill it with 16 words
            RoverList myList = new RoverList();

            String[] data = "Success is not final, failure is not fatal: it is the courage to continue that counts".Split(' ');

            foreach (string a in data)
            {
                myList.Add(a);
            }

            //Print out the list
            Console.Write("LIST: ");
            myList.ListNodes();
            Console.WriteLine();
            //Remove every 3rd word
            for (int i = myList.Count; i > 0; i--)
            {
                if (i % 3 == 0)
                {
                    myList.RemoveAt(i - 1);
                }
            }

            //Print out the list
            Console.Write("\nLIST: ");
            myList.ListNodes();
            Console.WriteLine("\n");

            //Prompt the user to input words, add those words to the list until they enter the word "done"
            bool end = false;

            while (!end)
            {
                Console.WriteLine("Input word(s) to be added to the list.  Type \"done\" when finished: ");
                string[] words = Console.ReadLine().Split(' ');
                for (int i = 0; i < words.Length; i++)
                {
                    if (words[i].ToUpper() == "DONE")
                    {
                        end = true;
                    }
                    else
                    {
                        myList.Add(words[i]);
                    }
                }
            }

            //Print out the list
            Console.Write("\nLIST: ");
            myList.ListNodes();
            Console.WriteLine("\n");

            //Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            end = false;
            while (!end)
            {
                Console.WriteLine("Input word(s) to be added to the front of the list.  Type \"done\" when finished:");
                string[] words = Console.ReadLine().Split(' ');
                for (int i = 0; i < words.Length; i++)
                {
                    if (words[i].ToUpper() == "DONE")
                    {
                        end = true;
                    }
                    else
                    {
                        myList.Add(0, words[i]);
                    }
                }
            }

            //Print out the list
            Console.Write("\nLIST: ");
            myList.ListNodes();
            Console.WriteLine();

            //Remove every word with an odd length
            for (int i = myList.Count - 1; i >= 0; i--)
            {
                if (((string)myList.ElementAt(i).Data).Length % 2 != 0)
                {
                    myList.RemoveAt(i);
                }
            }

            //Print out the list
            Console.Write("\nLIST: ");
            myList.ListNodes();
            Console.WriteLine();

            //Clear the list
            myList.Clear();

            //Print out the list
            Console.Write("\nLIST: ");
            myList.ListNodes();
            Console.WriteLine("\n");
        }
예제 #15
0
        static void Main(string[] args)
        {
            RoverList <string> list = new RoverList <string>();

            // TODO:  Implement the RoverList class
            // TODO:  Create a RoverList and then fill it with 16 words
            list.Add("Hello");
            list.Add("World");
            list.Add("Sixteen");
            list.Add("Dog");
            list.Add("Bird");
            list.Add("Cat");
            list.Add("Apple");
            list.Add("Orange");
            list.Add("Blue");
            list.Add("Green");
            list.Add("Banana");
            list.Add("Water");
            list.Add("This");
            list.Add("is");
            list.Add("a");
            list.Add("word.");

            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Prompt the user to input words, add those words to the list until they enter the word "done"
            bool finished = false;

            while (!finished)
            {
                Console.WriteLine("Enter a word to add to the list. Input done if you have finished.");
                String input = Console.ReadLine();
                if (input != "done")
                {
                    list.Add(input);
                }
                else
                {
                    finished = true;
                }
            }
            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Prompt the user to input words, add those words to the FRONT of the list until they enter the word "done"
            finished = false;
            while (!finished)
            {
                Console.WriteLine("Enter a word to add to the front of the list. Input done if you have finished.");
                String input = Console.ReadLine();
                if (input != "done")
                {
                    list.Add(input, 0);
                }
                else
                {
                    finished = true;
                }
            }
            // TODO:  Print out the list
            list.ListNodes();
            // TODO:  Remove every word with an odd length

            for (int i = 0; i < list.GetCount(); i++)
            {
                if (list.GetNode(i).Data.Length % 2 != 0)
                {
                    list.RemoveAt(i);
                }
            }
            // TODO:  Print out the list
            list.ListNodes();

            // TODO:  Clear the list
            list.Clear();
            // TODO:  Print out the list
            list.ListNodes();
        }