示例#1
0
 public TheatreEngine(IPerformanceDatabase performanceDatabase, ICommandFactory commandFactory, IInputHandler inputHandler, IRenderer renderer)
 {
     this.PerformanceDatabase = performanceDatabase;
     this.CommandFactory      = commandFactory;
     this.InputHandler        = inputHandler;
     this.Renderer            = renderer;
 }
示例#2
0
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase database)
        {
            var performances = database.ListAllPerformances().ToList();
            if (!performances.Any())
            {
                return "No performances";
            }

            var sb = new StringBuilder();

            //sb.AppendFormat("({0}, {1}, {2}), ",
            //        performances[0].PerformanceTitle,
            //        performances[0].TheatreName,
            //        performances[0].StartDateTime.ToString("dd.MM.yyyy HH:mm"));

            for (int i = 0; i < performances.Count; i++)
            {
                sb.AppendFormat("({0}, {1}, {2}), ",
                    performances[i].PerformanceTitle,
                    performances[i].TheatreName,
                    performances[i].StartDateTime.ToString("dd.MM.yyyy HH:mm"));
            }

            return sb.ToString().Trim(' ', ',');
        }
示例#3
0
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase database)
        {
            var performances = database.ListAllPerformances().ToList();

            if (!performances.Any())
            {
                return("No performances");
            }

            var sb = new StringBuilder();

            //sb.AppendFormat("({0}, {1}, {2}), ",
            //        performances[0].PerformanceTitle,
            //        performances[0].TheatreName,
            //        performances[0].StartDateTime.ToString("dd.MM.yyyy HH:mm"));

            for (int i = 0; i < performances.Count; i++)
            {
                sb.AppendFormat("({0}, {1}, {2}), ",
                                performances[i].PerformanceTitle,
                                performances[i].TheatreName,
                                performances[i].StartDateTime.ToString("dd.MM.yyyy HH:mm"));
            }

            return(sb.ToString().Trim(' ', ','));
        }
示例#4
0
        public static string ExecuteAddTheatreCommand(string[] parameters, IPerformanceDatabase database)
        {
            string theatreName = parameters[0];

            database.AddTheatre(theatreName);
            return("Theatre added");
        }
        public static string ExecuteAddTheatreCommand(string[] parameters, IPerformanceDatabase database)
        {
            string theatreName = parameters[0];
            database.AddTheatre(theatreName);

            return "Theatre added";
        }
示例#6
0
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase dataBase)
        {
            var performances = dataBase.ListAllPerformances().ToList();
            var result = string.Empty;
            if (performances.Any())
            {
                for (var i = 0; i < performances.Count; i++)
                {
                    var sb = new StringBuilder();
                    sb.Append(result);
                    if (i > 0)
                    {
                        sb.Append(", ");
                    }
                    var result1 = performances[i].Date.ToString("dd.MM.yyyy HH:mm");
                    sb.AppendFormat(
                        "({0}, {1}, {2})", performances
                            [i].PefrofmanceName, performances[i].Theatre, result1);
                    result = sb + "";
                }
                return result;
            }

            return "No performances";
        }
        public static string ExecutePrintAllPerformancesCommand(IPerformanceDatabase database)
        {
            var performances = database.ListAllPerformances().ToList();
            var performanceOutput = new StringBuilder();
            if (!performances.Any())
            {
                return "No performances";
            }

            for (int i = 0; i < performances.Count; i++)
            {
                //PERFORMANCE
                if (i > 0)
                {
                    performanceOutput.Append(", ");
                }

                string startDateTimeAsString = performances[i].StartDateTime.ToString("dd.MM.yyyy HH:mm");
                performanceOutput.AppendFormat(
                    "({0}, {1}, {2})",
                    performances[i].PerformanceTitle,
                    performances[i].TheatreName,
                    startDateTimeAsString);
            }

            return performanceOutput.ToString();
        }
示例#8
0
        public virtual ICommand CreateCommand(string commandName, IPerformanceDatabase performanceDatabase, IRenderer renderer)
        {
            ICommand command = null;

            switch (commandName.ToLower())
            {
            case "addperformance":
                command = new AddPerformanceCommand(performanceDatabase, renderer);
                break;

            case "addtheatre":
                command = new AddTheatreCommand(performanceDatabase, renderer);
                break;

            case "printallperformances":
                command = new PrintAllPerformancesCommand(performanceDatabase, renderer);
                break;

            case "printalltheatres":
                command = new PrintAllTheatresCommand(performanceDatabase, renderer);
                break;

            case "printperformances":
                command = new PrintPerformancesCommand(performanceDatabase, renderer);
                break;

            default:
                throw new ArgumentException("Invalid command!");
            }

            return(command);
        }
示例#9
0
        public void InitializeTest()
        {
            this.performances = new PerformanceDatabase();
            this.performances.AddTheatre("Theatre Sofia");
            this.performances.AddTheatre("Theatre 199");

            // Theatre 199, Duende, 20.01.2015 20:00, 1:30, 14.5
            this.performance1 = new Performance(
                "Theatre 199", 
                "Duende", 
                new DateTime(2015, 1, 19, 20, 0, 0), 
                new TimeSpan(0, 1, 30, 0), 
                14.5M);

            // Theatre 199, Bella Donna, 20.01.2015 20:30, 1:00, 12)
            this.performance2 = new Performance(
                "Theatre 199", 
                "Bella Donna", 
                new DateTime(2015, 1, 20, 20, 30, 0), 
                new TimeSpan(0, 1, 0, 0), 
                12.0M);

            // Theatre Sofia, Don Juan, 20.01.2015 20:31, 2:00, 14.60
            this.performance3 = new Performance(
                "Theatre Sofia", 
                "Don Juan", 
                new DateTime(2015, 1, 20, 20, 31, 0), 
                new TimeSpan(0, 2, 0, 0), 
                14.6M);
        }
示例#10
0
 public AppEngine(ICommandManager commandManager, IPerformanceDatabase performanceDatabase,
                  IRenderer renderer, IInputHandler inputHandler)
 {
     this.commandManager      = commandManager;
     this.PerformanceDatabase = performanceDatabase;
     this.renderer            = renderer;
     this.inputHandler        = inputHandler;
 }
示例#11
0
        public static string ExecuteAddPerformanceCommand(IPerformanceDatabase dataBase, AddPerformanceCommand command)
        {
            dataBase.AddPerformance(
                command.Theatre,
                command.Performance,
                command.Date,
                command.Duration,
                command.Price);

            return "Performance added";
        }
示例#12
0
        public static string ExecuteAddPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string theatreName = commandParams[0];
            string performanceTitle = commandParams[1];
            DateTime startDateTime = DateTime.ParseExact(commandParams[2],
                "dd.MM.yyyy HH:mm",
                CultureInfo.InvariantCulture);
            TimeSpan duration = TimeSpan.Parse(commandParams[3]);
            decimal price = decimal.Parse(commandParams[4], NumberStyles.Float);

            database.AddPerformance(theatreName,
                performanceTitle,
                startDateTime,
                duration,
                price);

            return "Performance added";
        }
示例#13
0
        public static string ExecutePrintPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string theatre = commandParams[0];
            var performances = database.ListOfPerformances(theatre)
                .Select(p => string.Format(
                    "({0}, {1})",
                    p.PerformanceTitle,
                    p.StartDateTime.ToString("dd.MM.yyyy HH:mm")))
                .ToList();

            if (performances.Any())
            {
                var result = string.Join(", ", performances);
                return result;
            }

            return "No performances";
        }
示例#14
0
        public static string ExecuteAddPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string   theatreName      = commandParams[0];
            string   performanceTitle = commandParams[1];
            DateTime startDateTime    = DateTime.ParseExact(commandParams[2],
                                                            "dd.MM.yyyy HH:mm",
                                                            CultureInfo.InvariantCulture);
            TimeSpan duration = TimeSpan.Parse(commandParams[3]);
            decimal  price    = decimal.Parse(commandParams[4], NumberStyles.Float);

            database.AddPerformance(theatreName,
                                    performanceTitle,
                                    startDateTime,
                                    duration,
                                    price);

            return("Performance added");
        }
示例#15
0
        public static string ExecutePrintPerformanceCommand(string[] commandParams, IPerformanceDatabase database)
        {
            string theatre      = commandParams[0];
            var    performances = database.ListOfPerformances(theatre)
                                  .Select(p => string.Format(
                                              "({0}, {1})",
                                              p.PerformanceTitle,
                                              p.StartDateTime.ToString("dd.MM.yyyy HH:mm")))
                                  .ToList();

            if (performances.Any())
            {
                var result = string.Join(", ", performances);
                return(result);
            }

            return("No performances");
        }
示例#16
0
        public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database)
        {
            var theatresCount = database.ListTheatres().Count();
            if (theatresCount > 0)
            {
                //var resultTheatres = new LinkedList<string>();
                //for (int i = 0; i < theatresCount; i++)
                //{
                //    database.ListTheatres().Skip(i).ToList().ForEach(t => resultTheatres.AddLast(t));
                //    foreach (var t in database.ListTheatres().Skip(i + 1))
                //    {
                //        resultTheatres.Remove(t);
                //    }
                //}
                return String.Join(", ", database.ListTheatres());
            }

            return "No theatres";
        }
        public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database)
        {
            var theatresCount = database.ListTheatres().Count();

            if (theatresCount == 0)
            {
                return "No theatres";
            }

            var resultTheatres = new LinkedList<string>();

            database.ListTheatres()
                    .ToList()
                    .ForEach(t => resultTheatres.AddLast(t));

            // PERFORMANCE: Useless iteration with foreach loop, which removes elements from Linkedlist
            // a slow operation
            return string.Join(", ", resultTheatres);
        }
示例#18
0
        public static string ExecutePrintAllTheatresCommand(IPerformanceDatabase database)
        {
            var theatresCount = database.ListTheatres().Count();

            if (theatresCount > 0)
            {
                //var resultTheatres = new LinkedList<string>();
                //for (int i = 0; i < theatresCount; i++)
                //{
                //    database.ListTheatres().Skip(i).ToList().ForEach(t => resultTheatres.AddLast(t));
                //    foreach (var t in database.ListTheatres().Skip(i + 1))
                //    {
                //        resultTheatres.Remove(t);
                //    }
                //}
                return(String.Join(", ", database.ListTheatres()));
            }

            return("No theatres");
        }
示例#19
0
        public static string ExecutePrintPerformancesCommand(IPerformanceDatabase dataBase,
            PrintPerformancesCommand command)
        {
            string result = String.Empty;
            var performances = dataBase.ListPerformances(command.TheatreName)
                            .Select(p =>
                            {
                                var result1 = p.Date.ToString("dd.MM.yyyy HH:mm");
                                return string.Format("({0}, {1})", p.PefrofmanceName, result1);
                            })
                            .ToList();

            if (performances.Any())
            {
                result = string.Join(", ", performances);
            }
            else
            {
                result = "No performances";
            }
            return result;
        }
 public PrintAllPerformancesCommand(string[] args, IPerformanceDatabase performanceDatabase)
     : base(args, performanceDatabase)
 {
 }
示例#21
0
 public Engine(IReader reader, IWriter writer, IPerformanceDatabase database)
 {
     this.reader = reader;
     this.writer = writer;
     this.database = database;
 }
 public CommandManager(IPerformanceDatabase performanceDatabas)
 {
     this.performanceDatabase = performanceDatabas;
 }
示例#23
0
 protected BaseCommand(string[] args, IPerformanceDatabase performanceDatabase)
 {
     this.CommandArgs = args;
     this.PerformanceDatabase = performanceDatabase;
 }
示例#24
0
 public void InitializeTest()
 {
     theatreDatabase = new PerformanceDatabase();
 }
示例#25
0
 protected AbstractCommand(IPerformanceDatabase performanceDatabase, IRenderer renderer)
 {
     this.PerformanceDatabase = performanceDatabase;
     this.Renderer            = renderer;
 }
 public void Initialize()
 {
     this.performanceDatabase = new PerformanceDatabase();
 }
 public AddPerformanceCommand(string[] args, IPerformanceDatabase performanceDatabase)
     : base(args, performanceDatabase)
 {
 }
 protected AbstractCommand(IPerformanceDatabase performanceDatabase)
 {
     this.performanceDatabase = performanceDatabase;
 }
示例#29
0
 public void SetUp()
 {
     this.data = new PerformanceDatabase();
 }
 public void InitializeTest()
 {
     this.database = new PerformanceDatabase();
 }
示例#31
0
 internal Engine(IPerformanceDatabase db, IInputMethod inputMethod, IOutputMethod outputMethod)
 {
     this.InputMethod = inputMethod;
     this.OutputMethod = outputMethod;
     this.DataBase = db;
 }
示例#32
0
 public string ExecuteAddTheaterCommand(IPerformanceDatabase performancesDatabase, string name)
 {
     performancesDatabase.AddTheater(name);
     return "Theatre added";
 }
 public void Inicialize_TestDatabase()
 {
     performanceDatabase = new PerformanceDatabase();
 }
示例#34
0
 public Engine(IPerformanceDatabase database, IInputReader reader, IOutputWriter writer)
 {
     this.database = database;
     this.reader = reader;
     this.writer = writer;
 }
示例#35
0
 public Engine(IReader reader, IWriter writer, IPerformanceDatabase database)
 {
     this.reader   = reader;
     this.writer   = writer;
     this.database = database;
 }
示例#36
0
 public void InitializeTest()
 {
     performanceDb = new PerformanceDatabase();
 }
 public AddPerformanceCommand(string[] inputArgs, IPerformanceDatabase performanceDatabase)
     : base(performanceDatabase)
 {
     this.parameters = inputArgs;
 }
 public CommandExecutor(IPerformanceDatabase performanceDatabase)
 {
     this.performanceDatabase = performanceDatabase;
 }
示例#39
0
 public TheatreEngine()
 {
     this.theatreDatabase = new PerformanceDatabase();
 }
示例#40
0
 public PrintPerformancesCommand(IPerformanceDatabase performanceDatabase, IRenderer renderer)
     : base(performanceDatabase, renderer)
 {
 }
示例#41
0
 public AddTheatreCommand(IPerformanceDatabase performanceDatabase, IRenderer renderer)
     : base(performanceDatabase, renderer)
 {
 }
 public PrintAllTheatresCommand(IPerformanceDatabase performanceDatabase)
     : base(performanceDatabase)
 {
 }
 public void InitializeDb()
 {
     this.db = new TheatreDatabase();
 }
 public InvalidResultCommand(IPerformanceDatabase performanceDatabase)
     : base(null)
 {
 }
示例#45
0
 public Engine(IPerformanceDatabase database, IUserInterface userInterface)
 {
     this.database      = database;
     this.userInterface = userInterface;
 }
示例#46
0
 public CommandManager(IPerformanceDatabase database, IAppender appender)
 {
     this.database = database;
     this.appender = appender;
 }
 public CommandManager(IPerformanceDatabase database, IAppender appender, IReader reader)
 {
     this.Database = database;
     this.Appender = appender;
     this.Reader   = reader;
 }