📄 freeticket.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
namespace GreenBirdCinema
{
/// <summary>
/// 赠票子类,继承父类Ticket,保存特殊的赠票信息.特有成员有获得赠票者的名字属性
/// </summary>
///
[Serializable]
class FreeTicket:Ticket
{
public FreeTicket() { }
public FreeTicket(ScheduleItem scheduleItem,Seat seat,string customerName):base(scheduleItem,seat)
{
this.CustomerName = customerName;
}
private string customerName; //赠票者的名字属性
public string CustomerName
{
get { return customerName; }
set { customerName = value; }
}
//重写父类的计算价格和打印的方法
public override void CalcPrice()
{
}
public override void Print()
{
this.FileName= this.ScheduleItem.Time + " " + this.Seat.SeatNumber + ".txt";
FileStream fs = new FileStream(FileName,FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.WriteLine("****************************");
sw.WriteLine("青鸟影院(赠票)");
sw.WriteLine("----------------------------");
sw.WriteLine("电影名:\t{0}", base.ScheduleItem.Movie.MovieName);
sw.WriteLine("时间:\t{0}", this.ScheduleItem.Time);
sw.WriteLine("座位号:\t{0}", this.Seat.SeatNumber);
sw.WriteLine("价格:\t{0}", base.Price.ToString());
sw.WriteLine("****************************");
sw.Close();
fs.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -