?? freeticket.cs
字號:
?using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace CinemaTicket
{
/// <summary>
/// 贈票
/// </summary>
class FreeTicket : Ticket,IPrintable
{
/// <summary>
/// 贈票特有屬性,獲得贈票者的名字
/// </summary>
private string customerName;
public string CustomerName
{
get { return customerName; }
set { customerName = value; }
}
/// <summary>
/// 重寫價格方法
/// </summary>
override public void CalcPrice()
{
this.Price = 0;
}
/// <summary>
/// 構造函數
/// </summary>
/// <param name="scheduleItem"></param>
/// <param name="seat"></param>
/// <param name="customerName"></param>
public FreeTicket(ScheduleItem scheduleItem, Seat seat, string customerName)
: base(scheduleItem,seat)
{
this.CustomerName = customerName;
}
/// <summary>
/// 實現打印接口
/// </summary>
#region IPrintable 成員
override public void Print()
{
string fileName = this.ScheduleItem.Time + " " + this.Seat.SeatNum + "_" + DateTime.Now.TimeOfDay.Seconds + ".txt";
FileStream fs = new FileStream(fileName, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("****************************");
sw.WriteLine(" 青鳥影院(贈票)");
sw.WriteLine("----------------------------");
sw.WriteLine(" 電影名: {0}", this.ScheduleItem.Movie.MovieName);
sw.WriteLine(" 時間: {0}", this.ScheduleItem.Time);
sw.WriteLine(" 座位號: {0}", this.Seat.SeatNum);
sw.WriteLine(" 贈送者: {0}", this.CustomerName);
sw.WriteLine(" 購票時間: {0}年{1}月{2}日", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
sw.WriteLine("----------------------------");
sw.Close();
fs.Close();
}
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -