Ejemplo n.º 1
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;
            }
            if (!(new string[] { "standard", "ranked" }).Contains(parts[2]))
            {
                Console.WriteLine("${ parts[2]} is not a supported type of gradebook, please try again");
                return;
            }

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

            if (parts[2] == "standard")
            {
                gradeBook = new StandardGradeBook(name, parts[3] == "true");
            }
            else if (parts[2] == "ranked")
            {
                gradeBook = new RankedGradeBook(name, parts[3] == "true");
            }
            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 typeOfGradeBook = parts[2];
            var isWeighted      = Convert.ToBoolean(parts[3]);

            if (typeOfGradeBook == "Standard")
            {
                StandardGradeBook gradeBook = new StandardGradeBook(name, isWeighted);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (typeOfGradeBook == "ranked")
            {
                RankedGradeBook gradeBook = new RankedGradeBook(name, isWeighted);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else
            {
                Console.WriteLine($"{typeOfGradeBook} is not a supported type of gradebook, please try again");
            }
        }
Ejemplo n.º 3
0
        public static void CreateCommand(string command)
        {
            var parts = command.Split(' ');

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

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

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

            default:
                Console.WriteLine(type + " 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];
            var           type   = parts[2];
            var           weight = bool.Parse(parts[3]);
            BaseGradeBook gradeBook;

            if (type.Equals("Standard", StringComparison.OrdinalIgnoreCase))
            {
                gradeBook = new StandardGradeBook(name, weight);
            }
            else if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, weight);
            }
            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);
        }
Ejemplo n.º 5
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  gradebook = parts[2];
            bool isWeighted;
            bool isParsedAsBool = Boolean.TryParse(parts[3], out isWeighted);

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

            if (gradebook.ToLower() == "standard" && isParsedAsBool)
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (gradebook.ToLower() == "ranked" && isParsedAsBool)
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine("Command not valid, Create requires a name, type of gradebook, if it's weighted (true / false).");
                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 weighted = bool.Parse(parts[3]);

            BaseGradeBook gradeBook;

            // 2 presents the third substring, parts will be set by user input, the second substring is the name of the gradebook, the third substring is the type of gradebook, and later the fourth will be if grading is weighted or not.

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name, weighted);
            }
            else if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, weighted);
            }
            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 != 3)
            {
                Console.WriteLine("Command not valid, Create requires a name and type of gradebook.");
                return;
            }
            var           name = parts[1];
            BaseGradeBook gradeBook;

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

            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
        private 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(standard / ranked), if it's weighted (true / false).");
                return;
            }
            var  name       = parts[1];
            var  type       = parts[2].ToLower();
            bool isWeighted = bool.Parse(parts[3]);

            if (type == "standard")
            {
                var gradeBook = new StandardGradeBook(name, isWeighted);
                Console.WriteLine($"Created {type} gradebook {name}.");
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (type == "ranked")
            {
                var gradeBook = new RankedGradeBook(name, isWeighted);
                Console.WriteLine($"Created {type} gradebook {name}.");
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (isWeighted == true)
            {
            }
            else
            {
                System.Console.WriteLine($"Command not valid, Create requires a name, type of gradebook(standard / ranked), if it's weighted (true / false).");
            }
        }
Ejemplo n.º 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];
            var type       = parts[2].ToLower();
            var isWeighted = bool.Parse(parts[3]);

            if (type.Equals("standard"))
            {
                StandardGradeBook gradeBook = new StandardGradeBook(name, isWeighted);
                Console.WriteLine($"Created {nameof(StandardGradeBook)} by the name of: {name}.");
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (type.Equals("ranked"))
            {
                RankedGradeBook gradeBook = new RankedGradeBook(name, isWeighted);
                Console.WriteLine($"Created {nameof(RankedGradeBook)} by the name of: {name}.");
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else
            {
                Console.WriteLine(type + " is not a supported type of gradebook, please try again");
            }
        }
        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           gradeType  = parts[2];
            var           isWeighted = parts[3];
            BaseGradeBook gradeBook  = new StandardGradeBook(name, false);

            if (gradeType == GradeBookType.Standard.ToString())
            {
                // gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (gradeType == GradeBookType.Ranked.ToString())
            {
                // gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine($"{gradeType} 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 != 3)
            {
                Console.WriteLine("Command not valid, Create requires a name and type of gradebook.");
                return;
            }
            var           name = parts[1];
            BaseGradeBook gradeBook;// = new BaseGradeBook(name);

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

            if (parts.Length != VALID_COMMAND_LENGTH)
            {
                Console.WriteLine(INVALID_COMMAND_LENGTH_MSG);
                return;
            }
            BaseGradeBook gradeBook  = null;
            var           name       = parts[1];
            string        type       = parts[2].ToLower();
            bool          isWeighted = bool.Parse(parts[3]);

            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);
        }
Ejemplo n.º 13
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];

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

            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);
        }
Ejemplo n.º 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[2];
            var isWeighted = string.Equals(parts[3], "true", StringComparison.OrdinalIgnoreCase);

            if (name == "standard")
            {
                BaseGradeBook gradeBook = new StandardGradeBook(name, isWeighted);
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            if (name == "ranked")
            {
                BaseGradeBook gradeBook = new RankedGradeBook(name, isWeighted);
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", name);
            }
        }
        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];

            if (Boolean.TryParse(parts[3], out bool result))
            {
                BaseGradeBook gradeBook;
                if (parts[2].Equals("standard"))
                {
                    gradeBook = new StandardGradeBook(name, result);
                }
                else if (parts[2].Equals("ranked"))
                {
                    gradeBook = new RankedGradeBook(name, result);
                }
                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);
            }
        }
Ejemplo n.º 16
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[2];
            bool          isWeighted = Convert.ToBoolean(parts[3]);
            BaseGradeBook gradeBook;

            if (name.Equals("standard"))
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (name.Equals("ranked"))
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine(String.Concat(name, " 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 != 3)
            {
                // Console.WriteLine("Command not valid, Create requires a name.");
                Console.WriteLine("Command not valid, Create requires a name and type of gradebook.");
                return;
            }
            var name = parts[1];
            var type = parts[2].ToLower();
            // BaseGradeBook gradeBook = new BaseGradeBook(name);
            BaseGradeBook gradeBook;

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name);
            }
            else if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name);
            }
            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);
        }
Ejemplo n.º 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 isWeighted = bool.Parse((parts[3]));

            BaseGradeBook gradeBook;

            if (type.Equals(GradeBookType.Standard))
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else if (type.Equals(GradeBookType.Ranked))
            {
                gradeBook = new RankedGradeBook(name, isWeighted);
            }
            else
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again.", type);
            }
        }
        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[2];
            var isWeighted = parts[3];

            if (name == "standard")
            {
                StandardGradeBook gradeBook = new StandardGradeBook(name, bool.Parse(isWeighted));
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }

            else if (name == "ranked")
            {
                StandardGradeBook gradeBook = new StandardGradeBook(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");
            }
        }
        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 weighted = Convert.ToBoolean(parts[3]);

            // Checks type input and instantiates gradeBook
            var type = parts[2].ToLower();

            if (type.Equals("standard"))
            {
                gradeBook = new StandardGradeBook(name, weighted);
            }
            else if (type.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}.", 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 isWeighted = bool.Parse(parts[3]);

            BaseGradeBook gradeBook;

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name, isWeighted);
            }
            else 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);
        }
Ejemplo n.º 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];
            //BaseGradeBook gradeBook = new BaseGradeBook(parts[2]);
            BaseGradeBook gradeBook;

            switch (parts[2].ToLower())
            {
            case "standard":
                gradeBook = new StandardGradeBook(name, Convert.ToBoolean(parts[3]));
                break;

            case "ranked":
                gradeBook = new RankedGradeBook(name, Convert.ToBoolean(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);
        }
Ejemplo n.º 23
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 = convert.toboolean(parts[3]);
            if (parts[2].ToLower() != "standard" && parts[2].ToLower() != "ranked")
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", parts[2]);
                return;
            }
            if (parts[3].ToString() != "true" && parts[3].ToString() != "false")
            {
                Console.WriteLine("Command not valid, create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            if (string.IsNullOrEmpty(parts[3]) || string.IsNullOrWhiteSpace(parts[3]))
            {
                Console.WriteLine("Command not valid, create requires a name, type of gradebook, if it's weighted (true / false).");
                return;
            }
            bool isWeighted = bool.Parse(parts[3].ToString());

            if (parts[2].ToLower() == "standard" && !(string.IsNullOrEmpty(parts[1])))
            {
                StandardGradeBook gradeBook = new StandardGradeBook(name, isWeighted);
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (parts[2].ToLower() == "ranked" && !(string.IsNullOrEmpty(parts[1])))
            {
                RankedGradeBook gradeBook = new RankedGradeBook(name, isWeighted);
                Console.WriteLine("Created gradebook {0}.", name);
                GradeBookUserInterface.CommandLoop(gradeBook);
            }
            else if (parts[2].ToLower() != "ranked" && parts[2].ToLower() != "standard")
            {
                Console.WriteLine("{0} is not a supported type of gradebook, please try again", parts[2]);
                return;
            }
            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);
        }
Ejemplo n.º 24
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].ToLower();
            var weighted = parts[3].ToLower();
            //try
            //{
            bool isWeighted = bool.Parse(weighted);
            //}
            //catch (Exception e)
            //{
            //    Console.WriteLine(e.ToString());
            //}
            //if (weighted.ToLower() == "yes" || weighted.ToLower() == "no")
            //{
            //    bool isWeighted = bool.Parse(weighted);

            //}
            //else { return; }

            BaseGradeBook gradeBook;

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



            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Ejemplo n.º 25
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  weightingstr = parts[3];
            bool weighting;

            if (weightingstr == "true")
            {
                weighting = true;
            }
            else if (weightingstr == "false")
            {
                weighting = false;
            }
            else
            {
                weighting = false;
            }

            BaseGradeBook gradeBook;

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name, weighting);
            }

            else if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, weighting);
            }

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


            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Ejemplo n.º 26
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 gradeBookType = parts[2].ToLower();

            // Determine if the gradebook should be weighted.
            bool isWeighted;

            if (parts[3].ToLower() == "true")
            {
                isWeighted = true;
            }
            else if (parts[3].ToLower() == "false")
            {
                isWeighted = false;
            }
            else
            {
                Console.WriteLine($"{parts[3]} is not valid, write 'true' or 'false'");
                return;
            }

            BaseGradeBook gradeBook;

            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);
        }
Ejemplo n.º 27
0
        public static void CreateCommand(string command)
        {
            /*
             * GradeBook.UserInterfaces.StartingUserInterface didn't write
             * 'Command not valid, Create requires a name and type of gradebook.'
             * to the console when the create command didn't contain both a name and type.
             */

            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;
            }
            else if (parts.Length == 3 && (parts[1] == null || parts[2] == null))
            {
                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 weighted = bool.Parse(parts[3]);

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

            BaseGradeBook gradeBook;

            if (type == "standard")
            {
                gradeBook = new StandardGradeBook(name, weighted);
            }
            else if (type == "ranked")
            {
                gradeBook = new RankedGradeBook(name, weighted);
            }
            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 strIsWeighted = parts[3].ToLower();

            string[] validBool  = { "true", "false" };
            bool     isWeighted = false;

            if (validBool.Contains(strIsWeighted))
            {
                isWeighted = (parts[3].ToLower() == "true");
            }
            else
            {
                Console.WriteLine($"'IsWeighted' must be 'true' or 'false', please try again");
                return;
            }

            BaseGradeBook gradeBook = null;

            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");
            }

            if (gradeBook != null)
            {
                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  isWeightedText = parts[3].ToLower();
            bool isWeighted;

            if (isWeightedText == "true")
            {
                isWeighted = true;
            }
            else if (isWeightedText == "false")
            {
                isWeighted = false;
            }
            else
            {
                Console.WriteLine("Command not valid, last word should be (true / false)");
                return;
            }
            BaseGradeBook gradeBook;

            if (type == "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;
            }

            //BaseGradeBook gradeBook = new BaseGradeBook(name);
            Console.WriteLine("Created gradebook {0}.", name);
            GradeBookUserInterface.CommandLoop(gradeBook);
        }
Ejemplo n.º 30
0
        public static void CreateCommand(string command)
        {
            BaseGradeBook gradeBook;
            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];
            string bookType = parts[2].ToLowerInvariant().ToString();

            bool isWeighted;

            if (parts[3].ToLowerInvariant().ToString() == "true")
            {
                isWeighted = true;
            }
            else if (parts[3].ToLowerInvariant().ToString() == "false")
            {
                isWeighted = false;
            }
            else
            {
                Console.WriteLine($"{parts[3].ToString()} is an invalid option. Please try again.");
                return;
            }

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

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