?? ticketfactory.cs
字號:
?using System;
using System.Collections.Generic;
using System.Text;
namespace CinemaTicket
{
/// <summary>
/// 簡單工廠,判斷創建不同的電影票對象
/// </summary>
class TicketFactory
{
public int ticketOOP(ScheduleItem sdi, Seat seat, int discount, string customerName,string type,Cinema cinema)
{
Ticket tt = null;
//判斷票務類型,分別創建對象
switch (type)
{
case "學生票":
tt = new StudentTicket(sdi, seat, discount);
cinema.SoldTickets.Add(tt);
break;
case "普通票":
tt = new Ticket(sdi, seat);
cinema.SoldTickets.Add(tt);
break;
case "贈票":
tt = new FreeTicket(sdi, seat, customerName);
cinema.SoldTickets.Add(tt);
break;
}
//執行計算價格及打印方法
tt.CalcPrice();
tt.Print();
return tt.Price;
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -