?? ticket.cs
字號:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace MyCinema
{
/// <summary>
/// 售票系統電影票的基類 可以實例化普通票
/// </summary>
[Serializable]
public class Ticket:IPrintable
{
public Ticket() { }
public Ticket(ScheduleItem scheduleItem, Seat seat)
{
this.ScheduleItem = scheduleItem;
this.Seat = seat;
}
/// <summary>
/// 座位對象
/// </summary>
private Seat seat;
public Seat Seat
{
get { return seat; }
set { seat = value; }
}
/// <summary>
/// 票價
/// </summary>
private int price;
public int Price
{
get { return price; }
set { price = value; }
}
/// <summary>
/// 所屬的放映場次
/// </summary>
private ScheduleItem scheduleItem;
public ScheduleItem ScheduleItem
{
get { return scheduleItem; }
set { scheduleItem = value; }
}
/// <summary>
/// 計算票價的方法
/// 可重寫
/// </summary>
public virtual void CalcPrice()
{
this.Price = this.ScheduleItem.Movie.Price;
}
#region IPrintable 成員
/// <summary>
/// 打印票接口的實現
/// </summary>
public virtual void Print()
{
string fileName = this.ScheduleItem.Time + " " + this.Seat.SeatNum + ".txt";
FileStream fs = new FileStream(fileName, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("***************************");
sw.WriteLine(" 青鳥影院");
sw.WriteLine("---------------------------");
sw.WriteLine(" 電影名:\t{0}", this.ScheduleItem.Movie.MovieName);
sw.WriteLine(" 時間:\t{0}", this.ScheduleItem.Time);
sw.WriteLine(" 座位號:\t{0}", this.Seat.SeatNum);
sw.WriteLine(" 價格:\t{0}", this.Price.ToString());
sw.WriteLine("***************************");
sw.Close();
fs.Close();
}
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -