📄 ticket.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace dianyingyuan
{
[Serializable]
class Ticket:Iprintshow
{
/// <summary>
/// 座位号
/// </summary>
private string seatNum;
public string SeatNum
{
get { return seatNum; }
set { seatNum = value; }
}
/// <summary>
/// 电影名
/// </summary>
private Movie dianying;
public Movie Dianying
{
get { return dianying; }
set { dianying = value; }
}
/// <summary>
/// 价格
/// </summary>
private int price;
public int Price
{
get { return price; }
set { price = value; }
}
/// <summary>
/// 时间
/// </summary>
private string showtime;
public string Showtime
{
get { return showtime; }
set { showtime = value; }
}
/// <summary>
/// 计算价格的虚方法
/// </summary>
public virtual void CalPrice()
{
this.Price = this.Dianying.Price;
}
public Ticket(string num,Movie name,int jiage,string time)
{
this.SeatNum = num;
this.Dianying = name;
this.Price = jiage;
this.Showtime = time;
}
#region Iprintshow 成员
public void printsa()
{
//文件名
string ticketFileName = this.Dianying.MovieName
+ this.Showtime.Replace(':', '-')
+ this.SeatNum + ".txt";
FileStream st = new FileStream(ticketFileName, FileMode.Create);
StreamWriter sw = new StreamWriter(st);
try
{
sw.WriteLine("*************************");
sw.WriteLine(" 小树影院 ");
sw.WriteLine("-------------------------");
sw.WriteLine("电影名:" + this.Dianying.MovieName);
sw.WriteLine("时间:" + this.Showtime);
sw.WriteLine("座位号:" + this.SeatNum);
sw.WriteLine("价格:" + this.Price.ToString());
sw.WriteLine("*************************");
}
catch (Exception ex)
{
throw ex;
}
finally
{
sw.Close();
}
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -