Exemplo n.º 1
0
 public static void displayboats(Boatsold personboat)
 {
     Console.WriteLine("Your first boat, a(n) {0}, has boat number {1}", personboat.boat1, personboat.boatNumber1);
     Console.WriteLine("Your second boat, a(n) {0}, has boat number {1}", personboat.boat2, personboat.boatNumber2);
     Console.WriteLine("Your third boat, a(n) {0}, has boat number {1}", personboat.boat3, personboat.boatNumber3);
     Console.WriteLine("Your fourth boat, a(n) {0}, has boat number {1}", personboat.boat4, personboat.boatNumber4);
     Console.WriteLine("Your fifth boat, a(n) {0}, has boat number {1}", personboat.boat5, personboat.boatNumber5);
 }
Exemplo n.º 2
0
        public static BoatsRacing converter5(Boatsold boat)
        {
            BoatsRacing racer1 = new BoatsRacing(boat.name, boat.boat5, boat.boatNumber5);

            return(racer1);
        }
Exemplo n.º 3
0
 public static void AddBoat(Boatsold personboat)
 {
     /*
      * Console.WriteLine("Would you like to add a new boat, Y/N?");
      * string response1 = Console.ReadLine();
      * if (response1 == "y" || response1 == "Y")
      * {
      *  Console.WriteLine("Enter boatname");
      *  string boat = Console.ReadLine();
      *  Console.WriteLine("Enter boatnumber");
      *  int boatnumber = int.Parse(Console.ReadLine());
      *
      *  using (IDbConnection connection = new MySql.Data.MySqlClient.MySqlConnection(Helper.CnnVal("sailingDB")))
      *  {
      *
      *      try
      *      {
      *          var boat1 = connection.Query<Boatsold>("call returnboat(@name)", new { name = personboat.name }).First();
      *          if (boat1.boat1 == "")
      *          {
      *              SQLAddboat(personboat.name, 0, boat, boatnumber);
      *          }
      *          else if (boat1.boat2 == "")
      *          {
      *              SQLAddboat(personboat.name, 1, boat, boatnumber);
      *          }
      *          else if (boat1.boat3 == "")
      *          {
      *              SQLAddboat(personboat.name, 2, boat, boatnumber);
      *          }
      *          else if (boat1.boat4 == "")
      *          {
      *              SQLAddboat(personboat.name, 3, boat, boatnumber);
      *          }
      *          else if (boat1.boat5 == "")
      *          {
      *              SQLAddboat(personboat.name, 4, boat, boatnumber);
      *          }
      *          else
      *          {
      *              Console.WriteLine("You have the max number of boats(5), would you like to remove one?");
      *              Console.WriteLine("Here are your 5 boats");
      *              displayboats(personboat);
      *              if (Console.ReadLine() == "Y" || Console.ReadLine() == "y")
      *              {
      *                  BoatsRacing boatsracing = new BoatsRacing();
      *                  Console.WriteLine("Which boat would you like to remove?");
      *                  var answer = Console.ReadLine();
      *                  if (answer == personboat.boat1)
      *                  {
      *                      boatsracing.name = personboat.name;
      *                      boatsracing.boatName = personboat.boat1;
      *                      boatsracing.boatNumber = personboat.boatNumber1;
      *                      LoadFullSQL.SQLremoveboat(personboat, boatsracing);
      *
      *                  }
      *                  else if (answer == personboat.boat2)
      *                  {
      *                      boatsracing.name = personboat.name;
      *                      boatsracing.boatName = personboat.boat2;
      *                      boatsracing.boatNumber = personboat.boatNumber2;
      *                      LoadFullSQL.SQLremoveboat(personboat, boatsracing);
      *
      *                  }
      *                  else if (answer == personboat.boat3)
      *                  {
      *                      boatsracing.name = personboat.name;
      *                      boatsracing.boatName = personboat.boat3;
      *                      boatsracing.boatNumber = personboat.boatNumber3;
      *                      LoadFullSQL.SQLremoveboat(personboat, boatsracing);
      *
      *                  }
      *                  else if (answer == personboat.boat4)
      *                  {
      *                      boatsracing.name = personboat.name;
      *                      boatsracing.boatName = personboat.boat4;
      *                      boatsracing.boatNumber = personboat.boatNumber4;
      *                      LoadFullSQL.SQLremoveboat(personboat, boatsracing);
      *
      *                  }
      *                  else if (answer == personboat.boat5)
      *                  {
      *                      boatsracing.name = personboat.name;
      *                      boatsracing.boatName = personboat.boat5;
      *                      boatsracing.boatNumber = personboat.boatNumber5;
      *                      LoadFullSQL.SQLremoveboat(personboat, boatsracing);
      *
      *                  }
      *                  else
      *                      Console.WriteLine("That is not one of the boats.");
      *
      *              }
      *          }
      *
      *      }
      *      catch
      *      {
      *          Console.WriteLine("Your name is not in my database");
      *      }
      *
      *
      *  }
      * }
      */
 }
Exemplo n.º 4
0
 public static void SQLremoveboat(Boatsold boats, BoatsRacing boat)
 {
     /*
      * if (boats.name == boat.name)
      * {
      *  boats.noOfBoats = boats.noOfBoats - 1;
      *  LoadFullSQL.SQLremove(false, boats.name);
      *  if (boats.boat1 == boat.boatName)
      *  {
      *      if (boats.noOfBoats == 1)
      *      {
      *          boats.boat1 = "";
      *          boats.boatNumber1 = 0;
      *      }
      *      else if (boats.noOfBoats == 2)
      *      {
      *          boats.boat1 = boats.boat2;
      *          boats.boat2 = "";
      *          boats.boatNumber1 = boats.boatNumber2;
      *          boats.boatNumber2 = 0;
      *      }
      *      else if (boats.noOfBoats == 3)
      *      {
      *          boats.boat1 = boats.boat3;
      *          boats.boat3 = "";
      *          boats.boatNumber1 = boats.boatNumber3;
      *          boats.boatNumber3 = 0;
      *      }
      *      else if (boats.noOfBoats == 4)
      *      {
      *          boats.boat1 = boats.boat4;
      *          boats.boat4 = "";
      *          boats.boatNumber1 = boats.boatNumber4;
      *          boats.boatNumber4 = 0;
      *      }
      *      else if (boats.noOfBoats == 5)
      *      {
      *          boats.boat1 = boats.boat5;
      *          boats.boat5 = "";
      *          boats.boatNumber1 = boats.boatNumber5;
      *          boats.boatNumber5 = 0;
      *      }
      *
      *  }
      *  else if (boats.boat2 == boat.boatName)
      *  {
      *      if (boats.noOfBoats == 2)
      *      {
      *          boats.boat2 = "";
      *          boats.boatNumber2 = 0;
      *      }
      *      else if (boats.noOfBoats == 3)
      *      {
      *          boats.boat2 = boats.boat3;
      *          boats.boat3 = "";
      *          boats.boatNumber2 = boats.boatNumber3;
      *          boats.boatNumber3 = 0;
      *      }
      *      else if (boats.noOfBoats == 4)
      *      {
      *          boats.boat2 = boats.boat4;
      *          boats.boat4 = "";
      *          boats.boatNumber2 = boats.boatNumber4;
      *          boats.boatNumber4 = 0;
      *      }
      *      else if (boats.noOfBoats == 5)
      *      {
      *          boats.boat2 = boats.boat5;
      *          boats.boat5 = "";
      *          boats.boatNumber2 = boats.boatNumber5;
      *          boats.boatNumber5 = 0;
      *      }
      *
      *
      *  }
      *
      *  else if (boats.boat3 == boat.boatName)
      *  {
      *      if (boats.noOfBoats == 3)
      *      {
      *          boats.boat3 = "";
      *          boats.boatNumber3 = 0;
      *      }
      *      else if (boats.noOfBoats == 4)
      *      {
      *          boats.boat3 = boats.boat4;
      *          boats.boat4 = "";
      *          boats.boatNumber3 = boats.boatNumber4;
      *          boats.boatNumber4 = 0;
      *      }
      *      else if (boats.noOfBoats == 5)
      *      {
      *          boats.boat3 = boats.boat5;
      *          boats.boat5 = "";
      *          boats.boatNumber3 = boats.boatNumber5;
      *          boats.boatNumber5 = 0;
      *      }
      *
      *  }
      *  else if (boats.boat4 == boat.boatName)
      *  {
      *      if (boats.noOfBoats == 4)
      *      {
      *          boats.boat4 = "";
      *          boats.boatNumber4 = 0;
      *      }
      *      else if (boats.noOfBoats == 5)
      *      {
      *          boats.boat4 = boats.boat5;
      *          boats.boat5 = "";
      *          boats.boatNumber4 = boats.boatNumber5;
      *          boats.boatNumber5 = 0;
      *      }
      *
      *  }
      *  else if (boats.boat5 == boat.boatName)
      *  {
      *      boats.boat5 = "";
      *      boats.boatNumber5 = 0;
      *
      *  }
      *
      *  LoadFullSQL.SQLAddboat(boats.name, boats.noOfBoats, boats.boat1, boats.boatNumber1);
      *  LoadFullSQL.SQLAddboat(boats.name, boats.noOfBoats, boats.boat2, boats.boatNumber2);
      *  LoadFullSQL.SQLAddboat(boats.name, boats.noOfBoats, boats.boat3, boats.boatNumber3);
      *  LoadFullSQL.SQLAddboat(boats.name, boats.noOfBoats, boats.boat4, boats.boatNumber4);
      *  LoadFullSQL.SQLAddboat(boats.name, boats.noOfBoats, boats.boat5, boats.boatNumber5);
      *  }
      */
 }
Exemplo n.º 5
0
        public static Dictionary <string, Boatsold> loadFullFile(string path)
        //public static string LoadFullFile()
        {
            StreamReader                  reader = System.IO.File.OpenText(@path + @"Full List.txt");
            string                        line;
            Dictionary <int, Boats>       BoatDictionaryInterim = new Dictionary <int, Boats>();
            Dictionary <string, Boatsold> BoatDictionary        = new Dictionary <string, Boatsold>();

            int count1 = 0;

            while ((line = reader.ReadLine()) != null)

            {
                string[] items = line.Split(char.Parse("\n"));

                while ((line = reader.ReadLine()) != null)
                {
                    /*
                     * string[] items1 = line.Split('\t');
                     * Boats boat1 = new Boats(items1[0], int.Parse(items1[1]), items1[2]);
                     * BoatDictionaryInterim.Add(count1, boat1);
                     */
                    count1++;
                }
            }
            List <string> keys = new List <string>();

            int m = 0;

            foreach (KeyValuePair <int, Boats> Boat in BoatDictionaryInterim)
            {
                if (keys.Contains(BoatDictionaryInterim[m].name))
                {
                    if (BoatDictionary[BoatDictionaryInterim[m].name].boat2 == null)
                    {
                        Boatsold boat1 = new Boatsold(BoatDictionaryInterim[m].name,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat1,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber1,
                                                      BoatDictionaryInterim[m].boatName,
                                                      BoatDictionaryInterim[m].boatNumber);
                        BoatDictionary.Remove(BoatDictionaryInterim[m].name);
                        BoatDictionary.Add(boat1.name, boat1);
                    }
                    else if (BoatDictionary[BoatDictionaryInterim[m].name].boat3 == null)
                    {
                        Boatsold boat1 = new Boatsold(BoatDictionaryInterim[m].name,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat1,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber1,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat2,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber2,
                                                      BoatDictionaryInterim[m].boatName,
                                                      BoatDictionaryInterim[m].boatNumber);
                        BoatDictionary.Remove(BoatDictionaryInterim[m].name);
                        BoatDictionary.Add(boat1.name, boat1);
                    }
                    else if (BoatDictionary[BoatDictionaryInterim[m].name].boat4 == null)
                    {
                        Boatsold boat1 = new Boatsold(BoatDictionaryInterim[m].name,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat1,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber1,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat2,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber2,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat3,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber3,
                                                      BoatDictionaryInterim[m].boatName,
                                                      BoatDictionaryInterim[m].boatNumber);
                        BoatDictionary.Remove(BoatDictionaryInterim[m].name);
                        BoatDictionary.Add(boat1.name, boat1);
                    }
                    else if (BoatDictionary[BoatDictionaryInterim[m].name].boat5 == null)
                    {
                        Boatsold boat1 = new Boatsold(BoatDictionaryInterim[m].name,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat1,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber1,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat2,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber2,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat3,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber3,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boat4,
                                                      BoatDictionary[BoatDictionaryInterim[m].name].boatNumber4,
                                                      BoatDictionaryInterim[m].boatName,
                                                      BoatDictionaryInterim[m].boatNumber);
                        BoatDictionary.Remove(BoatDictionaryInterim[m].name);
                        BoatDictionary.Add(boat1.name, boat1);
                    }
                }
                else
                {
                    Boatsold boat3 = new Boatsold(BoatDictionaryInterim[m].name,
                                                  BoatDictionaryInterim[m].boatName,
                                                  BoatDictionaryInterim[m].boatNumber);
                    BoatDictionary.Add(boat3.name, boat3);
                    keys.Add(BoatDictionaryInterim[m].name);
                }
                m++;
            }
            reader.Close();
            return(BoatDictionary);
        }
Exemplo n.º 6
0
        //public List<Boats> boatlist = new List<Boats>();
        //public Boats personboat = new Boats();
        //public static void Main1()
        public static void hello(string name)
        {
            //Boats boat1 = new Boats("Adrian Stanislaus", 2, "Laser Stratos", 927, "Laser", 182782);
            //Boats boat2 = new Boats("Luke Stanislaus", 1, "Laser Stratos", 182782, null, 0);
            //Boats boat3 = new Boats("Simon Clark", 2, "Phantom", 1080, "Laser", 1234);
            //List<Boats> boat = new Dictionary<string, Boats>();
            List <BoatsRacing> raceList   = new List <BoatsRacing>();
            List <Boatsold>    boatlist   = new List <Boatsold>();
            Boatsold           personboat = new Boatsold();

            //Console.WriteLine("Enter path to folder of files");
            string[] path1 = System.Reflection.Assembly.GetEntryAssembly().Location.Split(char.Parse(@"\"));
            string   path  = "";
            int      b     = 0;

            while (path1[b] != "SailingUWP")
            {
                path = string.Concat(path + path1[b] + @"\");
                b++;
            }
            //string path2 = path.Split(path)

            /*
             * Console.WriteLine("Enter name");
             * string name1 = Console.ReadLine();
             * LoadFullSQL db = new LoadFullSQL();
             * boatlist = db.GetBoats();
             * Console.WriteLine(db.GetBoat(name1).boat1);
             */
            //boatDictionary = LoadFullSQL.getdictionary(boatlist);

            /*
             * Console.WriteLine("Enter name");
             * string name2 = Console.ReadLine();
             * Console.WriteLine("Enter boatname");
             * string boatname2 = Console.ReadLine();
             * Console.WriteLine("Enter boatnumber");
             * int boatnumber2 = int.Parse(Console.ReadLine());
             * if (LoadFullSQL.AddBoat(name2, boatname2, boatnumber2) == true)
             *  Console.WriteLine("Success");
             * else
             *  Console.WriteLine("Fail");
             */
            //boatDictionary = LoadFullFile.loadFullFile(path);
            //Console.WriteLine(boatDictionary["Adrian Stanislaus"].boat1);
            //string hi = LoadFullFile();
            //Console.WriteLine(boatDictionary["Abc"].name);
            //boatDictionary.Add(boat1.name, boat1);
            //boatDictionary.Add(boat2.name, boat2);
            //boatDictionary.Add(boat3.name, boat3);
            //LoadFullFile.ExportToFile(boatDictionary, path);

            /*
             * while (0==1)
             * {
             *  Console.WriteLine("Who is it?");
             *  string person = name;
             *  try
             *  {
             *      LoadFullSQL db1 = new LoadFullSQL();
             *      //Boats personboat = db1.GetBoat(person);
             *      personboat = db1.GetBoat(person);
             *      while (person == personboat.name)
             *      {
             *
             *          if (personboat.noOfBoats > 0)
             *          {
             *              Console.WriteLine("Is your boat a(n) {0}, Y/N?", personboat.boat1);
             *              string response = Console.ReadLine();
             *              if (response == "Y" || response == "y")
             *              {
             *
             *                  //BoatsRacing.converter1(personboat);
             *                  LoadFullSQL.SQLaddnewracer(personboat, BoatsRacing.converter1(personboat));
             *                  Console.ReadLine();
             *
             *                  break;
             *
             *              }
             *              else if (personboat.noOfBoats == 1)
             *              {
             *                  LoadFullSQL.AddBoat(personboat);
             *              }
             *          }
             *          if (personboat.noOfBoats > 1)
             *          {
             *              Console.WriteLine("Is your boat a(n) {0}, Y/N?", personboat.boat2);
             *              string response = Console.ReadLine();
             *              if (response == "Y" || response == "y")
             *              {
             *
             *                  LoadFullSQL.SQLaddnewracer(personboat, BoatsRacing.converter1(personboat));
             *                  Console.ReadLine();
             *                  break;
             *
             *              }
             *              else if (personboat.noOfBoats == 2)
             *              {
             *                  LoadFullSQL.AddBoat(personboat);
             *              }
             *          }
             *          if (personboat.noOfBoats > 2)
             *          {
             *              Console.WriteLine("Is your boat a(n) {0}, Y/N?", personboat.boat3);
             *              string response = Console.ReadLine();
             *              if (response == "Y" || response == "y")
             *              {
             *
             *                  LoadFullSQL.SQLaddnewracer(personboat, BoatsRacing.converter1(personboat));
             *                  Console.ReadLine();
             *                  break;
             *
             *              }
             *              else if (personboat.noOfBoats == 3)
             *              {
             *                  LoadFullSQL.AddBoat(personboat);
             *              }
             *          }
             *          if (personboat.noOfBoats > 3)
             *          {
             *              Console.WriteLine("Is your boat a(n) {0}, Y/N?", personboat.boat4);
             *              string response = Console.ReadLine();
             *              if (response == "Y" || response == "y")
             *              {
             *
             *                  LoadFullSQL.SQLaddnewracer(personboat, BoatsRacing.converter1(personboat));
             *                  Console.ReadLine();
             *                  break;
             *
             *              }
             *              else if (personboat.noOfBoats == 4)
             *              {
             *                  LoadFullSQL.AddBoat(personboat);
             *              }
             *          }
             *          if (personboat.noOfBoats > 4)
             *          {
             *              Console.WriteLine("Is your boat a(n) {0}, Y/N?", personboat.boat5);
             *              string response = Console.ReadLine();
             *              if (response == "Y" || response == "y")
             *              {
             *
             *                  LoadFullSQL.SQLaddnewracer(personboat, BoatsRacing.converter1(personboat));
             *                  Console.ReadLine();
             *                  break;
             *
             *              }
             *              else if (personboat.noOfBoats == 5)
             *              {
             *                  LoadFullSQL.AddBoat(personboat);
             *              }
             *          }
             *          Console.Clear();
             *          personboat = db1.GetBoat(person);
             *      }
             *  }
             *
             *  catch (KeyNotFoundException)
             *  {
             *
             *
             *  }
             *  //Dictionary<string, Boats> nothing = new Dictionary<string, Boats>();
             *  //boatDictionary = LoadFullFile.loadFullFile(path);
             *  //string hi2 = LoadFullFile();
             *  Console.Clear();
             *  Console.WriteLine("Escape, Y/N?");
             *  if (Console.ReadLine() == "y" || Console.ReadLine() == "Y")
             *      break;
             *
             * }
             * foreach (var item in raceList)
             * {
             *  Console.WriteLine("Name = {0}, BoatName = {1}, BoatNumber = {2}", item.name, item.boatName, item.boatNumber);
             * }
             * Console.ReadLine();
             * /*
             * Console.WriteLine("Would you like to remove a boat?");
             * if (Console.ReadLine() == "y" || Console.ReadLine() == "Y")
             * {
             *  LoadFullSQL.SQLremoveboat()
             * }
             */
        }