コード例 #1
0
ファイル: Ticket.cs プロジェクト: ikolev94/Exercises
        public int CompareTo(Ticket otherTicket)
        {
            int compareToResult = this.DateAndTime.CompareTo(otherTicket.DateAndTime);
            if (compareToResult == 0)
            {
                compareToResult = this.Type.CompareTo(otherTicket.Type);
            }

            if (compareToResult == 0)
            {
                compareToResult = this.Price.CompareTo(otherTicket.Price);
            }

            return compareToResult;
        }
コード例 #2
0
ファイル: TicketCatalog.cs プロジェクト: ikolev94/Exercises
        private string DeleteTicket(Ticket ticket)
        {
            string key = ticket.UniqueKey;
            if (this.ticketesByUniqueKey.ContainsKey(key))
            {
                ticket = this.ticketesByUniqueKey[key];
                this.ticketesByUniqueKey.Remove(key);
                string fromToKey = ticket.FromToKey;

                this.ticketsByFromToKey.Remove(fromToKey, ticket);
                this.ticketsByDate.Remove(ticket.DateAndTime, ticket);
                return "Ticket deleted";
            }
            else
            {
                return "Ticket does not exist";
            }
        }
コード例 #3
0
ファイル: TicketCatalog.cs プロジェクト: ikolev94/Exercises
        private string AddTicket(Ticket ticket)
        {
            string key = ticket.UniqueKey;
            if (this.ticketesByUniqueKey.ContainsKey(key))
            {
                return "Duplicate ticket";
            }
            else
            {
                this.ticketesByUniqueKey.Add(key, ticket);
                string fromToKey = ticket.FromToKey;

                this.ticketsByFromToKey.Add(fromToKey, ticket);
                this.ticketsByDate.Add(ticket.DateAndTime, ticket);
                return "Ticket added";
            }
        }