Beispiel #1
0
        public static void LoadCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 2)
            {
                Console.WriteLine("Command not valid, Load requires a name.");
                return;
            }
            var name      = parts[1];
            var gradeBook = BaseGradeBook.Load(name);

            if (gradeBook == null)
            {
                return;
            }

            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            bool isWeighted;
            var  name     = parts[1];
            var  type     = parts[2].ToLower();
            var  weighted = parts[3].ToLower();

            if (weighted == "true")
            {
                isWeighted = true;
            }
            else
            {
                isWeighted = false;
            }


            BaseGradeBook gradeBook;

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", type);
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name      = parts[1];
            var type      = parts[2].ToLower();
            var condition = false;

            if (parts[3] == "Y")
            {
                condition = true;
            }
            else
            {
                condition = false;
            }

            //BaseGradeBook gradeBook = new BaseGradeBook(name);
            BaseGradeBook gradeBook;

            switch (type)
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, condition);
                break;

            case "ranked":
                gradeBook = new RankedGradeBook(name, condition);
                break;

            default:
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", type);
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void LoadCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 2)
            {
                Console.WriteLine("command not valid, create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name      = parts[1];
            var gradeBook = BaseGradeBook.Load(name);

            if (gradeBook == null)
            {
                return;
            }

            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }

            var           name       = parts[1];
            var           isWeighted = false;
            BaseGradeBook gradeBook  = null;

            if (bool.TryParse(parts[3], out isWeighted))
            {
                switch (parts[2])
                {
                case "standard":
                    gradeBook = new StandardGradeBook(name, isWeighted);
                    break;

                case "ranked":
                    gradeBook = new RankedGradeBook(name, isWeighted);
                    break;

                default:
                    Console.WriteLine($"{parts[2]} is not a supported type of gradebook, please try again");
                    break;
                }

                if (gradeBook != null)
                {
                    Console.WriteLine("Created gradebook {0}.", name);
                    GradeBookUserInterface.CommandLoop(gradeBook);
                }
            }
            else
            {
                Console.WriteLine($"{parts[3]} cannot be coverted as true or false");
            }
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var  name             = parts[1];
            var  type             = parts[2];
            var  isWeightedString = parts[3];
            bool isWeighted;

            if (isWeightedString == "true")
            {
                isWeighted = true;
            }
            else
            {
                isWeighted = false;
            }

            BaseGradeBook gradeBook;

            switch (type)
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, isWeighted);
                break;

            case "ranked":
                gradeBook = new RankedGradeBook(name, isWeighted);
                break;

            default:
                Console.WriteLine(parts[2] + " is not a supported type of gradebook, please try again");
                return;
            }
            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Beispiel #7
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var  name     = parts[1];
            var  weighted = parts[3];
            bool weight;

            if (weighted == bool.TrueString)
            {
                weight = true;
            }
            else
            {
                weight = false;
            }


            if (parts[2] == "standard")
            {
                BaseGradeBook gradeBook = new StandardGradeBook(name, weight);
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (parts[2] == "ranked")
            {
                BaseGradeBook gradeBook = new RankedGradeBook(name, weight);
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else
            {
                Console.WriteLine(command + " is not a supported type of gradebook, please try again");
                return;
            }
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name       = parts[1];
            var           type       = parts[2];
            var           isWeighted = bool.Parse(parts[3]);
            GradeBookType bookType;
            BaseGradeBook gradeBook;

            if (Enum.TryParse(type, true, out bookType))
            {
                switch (bookType)
                {
                case GradeBookType.Ranked:
                    gradeBook = new RankedGradeBook(name, isWeighted);
                    break;

                case GradeBookType.Standard:
                    gradeBook = new StandardGradeBook(name, isWeighted);
                    break;

                default:
                    Console.WriteLine(type + " is not a supported type of gradebook, please try again");
                    return;
                }
            }
            else
            {
                Console.WriteLine(type + " is not a supported type of gradebook, please try again");
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Beispiel #9
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name = parts[1];

            object gradeBook = new object();

            var IsWeighted = false;

            bool.TryParse(parts[3], out IsWeighted);



            switch (parts[2])
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, IsWeighted);
                break;

            case "ranked":
                gradeBook = new RankedGradeBook(name, IsWeighted);
                break;
            }

            if (parts[2] != "standard" || parts[2] != "ranked")
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", parts[2]);
                return;
            }

            //BaseGradeBook gradeBook = new BaseGradeBook(name);
            //Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop((BaseGradeBook)gradeBook);
        }
Beispiel #10
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name = parts[1];
            BaseGradeBook gradeBook;

            var typeStr    = parts[2];
            var isWeighted = Boolean.Parse(parts[3]);

            switch (typeStr)
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, isWeighted);
                break;

            case "ranked":
                gradeBook = new RankedGradeBook(name, isWeighted);
                break;

            default:
                gradeBook = null;
                break;
            }

            if (gradeBook == null)
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", typeStr);
            }
            else
            {
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
        }
Beispiel #11
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name     = parts[1];
            var type     = parts[2];
            var weighted = false;

            if (parts[3].ToLower().Equals("true") || parts[3].ToLower().Equals("false"))
            {
                weighted = Convert.ToBoolean(parts[3].ToLower());
            }
            else
            {
                Console.WriteLine($"Last argument can only be true or false. You have entered {parts[3]}.");
                return;
            }
            BaseGradeBook gradeBook;

            if (type.ToLower().Equals("standard"))
            {
                gradeBook = new StandardGradeBook(name, weighted);
            }
            else if (type.ToLower().Equals("ranked"))
            {
                gradeBook = new RankedGradeBook(name, weighted);
            }
            else
            {
                Console.WriteLine($"{type} is not a supported type of gradebook, please try again");
                return;
            }
            Console.WriteLine("Created gradebook {0} of type {1}. Grade Book is weighted: {2}", name, type, weighted);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');
            var name  = parts[1];

            if (parts.Length == 4)
            {
                bool isWeighted = Convert.ToBoolean(parts[3]);
                switch (parts[2])
                {
                case "standard":
                {
                    StandardGradeBook standard = new StandardGradeBook(name, isWeighted);
                    GradeBookUserInterface.CommandLoop(standard);
                    break;
                }

                case "ranked":
                {
                    RankedGradeBook ranked = new RankedGradeBook(name, isWeighted);
                    GradeBookUserInterface.CommandLoop(ranked);
                    break;
                }

                default:
                    Console.WriteLine(name + "is not a supported type of gradebook, please try again");
                    break;
                }
            }
            else
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            ;

            //   BaseGradeBook gradeBook = new BaseGradeBook(name);
            Console.WriteLine("Created gradebook {0}.", name);
            //   GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name       = parts[1];
            var typeOfBook = parts[2].ToLower();

            bool isWeighted;

            if (!bool.TryParse(parts[3], out isWeighted))
            {
                Console.WriteLine("The third parameter was not recognized.");
                return;
            }

            BaseGradeBook gradeBook;

            switch (typeOfBook)
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, isWeighted);
                break;

            case "ranked":
                gradeBook = new RankedGradeBook(name, isWeighted);
                break;

            default:
                Console.WriteLine($"{parts[2]} is not a supported type of gradebook, please try again");
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Beispiel #14
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name = parts[1];

            bool isWeighted;

            if (parts[3].ToLower() == "true")
            {
                isWeighted = true;
            }
            else if (parts[3].ToLower() == "false")
            {
                isWeighted = false;
            }
            else
            {
                Console.WriteLine("isWeighted parameter can be either true or false");
                return;
            }

            if (parts[2].ToLower() == "standard")
            {
                GradeBookUserInterface.CommandLoop(new StandardGradeBook(name, isWeighted));
            }
            else if (parts[2].ToLower() == "ranked")
            {
                GradeBookUserInterface.CommandLoop(new RankedGradeBook(name, isWeighted));
            }
            else
            {
                Console.WriteLine("{0} is not supported type of gradebook, please try again", parts[2]);
            }
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var  name = parts[1];
            var  type = parts[2];
            bool isWeighted;

            bool success = bool.TryParse(parts[3], out isWeighted);

            if (!success)
            {
                Console.WriteLine($"{parts[3]} is not a valid value. Choose true for weighted and false for not weighted.");
                return;
            }

            BaseGradeBook gradeBook;

            if (type.ToLower() == "standard")
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine($"{type} is not a supported type of gradebook, please try again");
                return;
            }

            Console.WriteLine($"Created {type} gradebook {name}.");
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }

            var  name       = parts[1];
            var  bookType   = parts[2];
            bool isWeighted = bool.TryParse(parts[3], out bool result);

            if (!result)
            {
                Console.WriteLine("{0} is not a valid value.", isWeighted);
                return;
            }

            BaseGradeBook gradeBook;

            if (bookType == GradeBookType.Standard.ToString())
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (bookType == GradeBookType.Ranked.ToString())
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again.", bookType);
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name          = parts[1];
            var           gradeBookType = parts[2].ToLower();
            bool          isWeighted;
            BaseGradeBook gradeBook = null;

            if (!Boolean.TryParse(parts[3], out isWeighted))
            {
                Console.WriteLine($"{parts[3]} is not a boolean. Please only use 'True' or 'False'");
            }

            switch (gradeBookType)
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, isWeighted);
                break;

            case "ranked":
                gradeBook = new RankedGradeBook(name, isWeighted);
                break;

            default:
                Console.WriteLine($"{parts[2]} is not a supported type of gradebook, please try again");
                return;
            }


            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Beispiel #18
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name = parts[1];
            var           type = parts[2];
            var           hasWeightParameter = Boolean.TryParse(parts[3], out bool weighted);
            BaseGradeBook gradeBook;

            if (hasWeightParameter)
            {
                if (type == "standard")
                {
                    gradeBook = new StandardGradeBook(name, weighted);
                }
                else if (type == "ranked")
                {
                    gradeBook = new RankedGradeBook(name, weighted);
                }
                else
                {
                    Console.WriteLine($"{type} is not a supported type of gradebook, please try again");
                    return;
                }
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else
            {
                Console.WriteLine("Command not valid. The last argument of the Create command needs to be a boolean (TRUE/FALSE)");
                return;
            }
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name = parts[1];
            BaseGradeBook gradeBook;
            var           type = parts[2];
            bool          isWeighted;

            try
            {
                isWeighted = Convert.ToBoolean(parts[3]);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to convert boolean: " + ex.Message);
                return;
            }

            switch (type)
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, isWeighted);
                break;

            default:
                Console.WriteLine(type + " is not a supported type of gradebook, please try again");
                return;
                //break;
            }
            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false)..");
                return;
            }
            //dodano
            string isWeighted = parts[3];

            if (isWeighted != "true" && isWeighted != "false")
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false)..");
            }


            var name = parts[2];

            if (name == "standard")
            {
                StandardGradeBook gradeBook = new StandardGradeBook(name, bool.Parse(isWeighted));
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (name == "ranked")
            {
                RankedGradeBook gradeBook = new RankedGradeBook(name, bool.Parse(isWeighted));
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else
            {
                Console.WriteLine($"{name} is not a supported type of gradebook, please try again");
            }
        }
Beispiel #21
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name = parts[1];
            BaseGradeBook gradeBook;

            bool isWeighted;

            if (!bool.TryParse(parts[3], out isWeighted))
            {
                Console.WriteLine($"{parts[3]} is not a valid bool type, please try again.");
                return;
            }

            if (parts[2].Equals("standard"))
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (parts[2].Equals("ranked"))
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine($"{parts[2]} is not a supported type of gradebook, please try again");
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Beispiel #22
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name = parts[1];
            var type = parts[2];

            if (bool.TryParse(parts[3], out bool isWeighted))
            {
                if (type == "standard")
                {
                    Console.WriteLine("Created standard gradebook {0}.", name);
                    var gradeBook = new StandardGradeBook(name, isWeighted);
                    GradeBookUserInterface.CommandLoop(gradeBook);
                }
                else if (type == "ranked")
                {
                    Console.WriteLine("Created ranked gradebook {0}.", name);
                    var gradeBook = new RankedGradeBook(name, isWeighted);
                    GradeBookUserInterface.CommandLoop(gradeBook);
                }
                else
                {
                    Console.WriteLine(type + " is not a supported type of gradebook, please try again");
                    return;
                }
            }
            else
            {
                return;
            }
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var name = parts[1];

            BaseGradeBook gradeBook = null /*new BaseGradeBook(name)*/;

            switch (parts[2])
            {
            case "standard":
            {
                gradeBook = new StandardGradeBook(name, bool.Parse(parts[3]));
                break;
            }

            case "ranked":
            {
                gradeBook = new RankedGradeBook(name, bool.Parse(parts[3]));
                break;
            }

            default:
            {
                Console.WriteLine($"{parts[2]} is not a supported type of gradebook, please try again");
                return;
            }
            }
            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name      = parts[1];
            BaseGradeBook gradeBook = null;
            bool          w         = false;

            if (parts[3].ToLower() == "true")
            {
                w = true;
            }
            if (parts[2].ToLower() == "standard")
            {
                gradeBook = new StandardGradeBook(name, w);
            }
            else if (parts[2].ToLower() == "ranked")
            {
                gradeBook = new RankedGradeBook(name, w);
            }
            else
            {
                Console.WriteLine(parts[2] + " is not a supported type of gradebook, please try again");
            }

            if (gradeBook != null)
            {
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
        }
Beispiel #25
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            /*if (parts.Length != 2)
             * {
             *  Console.WriteLine("Command not valid, Create requires a name.");
             *  return;
             * }*/
            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name     = parts[1];
            var           type     = parts[2];
            var           weighted = bool.Parse(parts[3]);
            BaseGradeBook gradeBook;

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name, weighted);
            }
            else if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, weighted);
            }
            else
            {
                Console.WriteLine($"{type} is not a supported type of gradebook, please try again");
                return;
            }
            //BaseGradeBook gradeBook = new BaseGradeBook(name);
            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var           name = parts[1];
            BaseGradeBook gradeBook;
            bool          isWeighted = Boolean.Parse(parts[3]);

            if (parts[3].ToLower() == "true")
            {
                isWeighted = true;
            }
            switch (parts[2])
            {
            case "Standard":
                gradeBook = new StandardGradeBook(name, isWeighted);
                Console.WriteLine("Created gradebook " + name);
                GradeBookUserInterface.CommandLoop(gradeBook);
                break;

            case "Ranked":
                gradeBook = new StandardGradeBook(name, isWeighted);
                Console.WriteLine("Created gradebook " + name);
                GradeBookUserInterface.CommandLoop(gradeBook);
                break;

            default:
                Console.WriteLine($"{parts[2]} is not a supported type of gradebook, please try again");
                break;
            }
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var  name       = parts[1];
            var  type       = parts[2];
            bool isWeighted = bool.TryParse(parts[3], out bool goodInput);

            if (goodInput == false)
            {
                Console.WriteLine("Weighting type not recognised - must be true / false .");
                return;
            }
            BaseGradeBook gradeBook;

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", type);
                return;
            }
            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Beispiel #28
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }

            string name          = parts[1];
            string gradeBookType = parts[2];
            bool   isWeighted    = false;

            bool.TryParse(parts[3], out isWeighted);

            // Instantiate the gradebook.
            BaseGradeBook gradeBook = null;

            if (gradeBookType == "standard")
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (gradeBookType == "ranked")
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine($"{gradeBookType} is not a supported type of gradebook, please try again");
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            var  name       = parts[1];
            bool isWeighted = false;

            //Setting isWeighted
            if (parts[3] == "true")
            {
                isWeighted = true;
            }

            BaseGradeBook gradeBook;// = new BaseGradeBook(name); Old implementation; leaving it here to denote a change

            if (parts[2] == "standard")
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (parts[2] == "ranked")
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine(parts[2] + " is not a supported type of gradebook, please try again");
                return;
            }
            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        public static void CreateCommand(string command)
        {
            string formatError = "Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).";

            var parts = command.Split(' ');

            if (parts.Length != 4)
            {
                Console.WriteLine(formatError);
                return;
            }

            var           name             = parts[1];
            var           gradeBookType    = parts[2].ToLower();
            bool          isWeighted       = Convert.ToBoolean(parts[3]);
            BaseGradeBook gradeBook        = null;
            string        typeErrorMessage = gradeBookType + " is not a supported type of gradebook, please try again";

            if (gradeBookType == "standard")
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (gradeBookType == "ranked")
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine(typeErrorMessage);
                return;
            }

            Console.WriteLine("Created gradebook {0}.", name);

            GradeBookUserInterface.CommandLoop(gradeBook);
        }