//工厂模式 public static TicKet CreateTicket(string type, ScheduleItem item, Seat seat, string customerName, double disCount) //买票 { TicKet t = null; switch (type) { case "TicKet": t = new TicKet(item, seat); break; case "FreeTicKet": t = new FreeTicket(item, seat, customerName); break; case "StuTicKet": t = new StudentTicket(item, seat, disCount); break; } return(t); }
public static Ticket CreateTicket(ScheduleItem scheduleItem, Seat seat, int discount, string customerName, string type) { Ticket newTicket = null; switch (type) { case "student": newTicket = new StudentTicket(scheduleItem, seat, discount); break; case "free": newTicket = new FreeTicket(scheduleItem, seat, customerName); break; case "": newTicket = new Ticket(scheduleItem, seat); break; } return(newTicket); }