⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ticket.cs

📁 ”青鸟影院”开始营业
💻 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 + -