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

📄 ticket.cs

📁 北大青鸟ACCP课程S2项目案例2影院售票系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace CinemaTicket
{
    /// <summary>
    /// 电影票父类,保存电影票信息
    /// </summary>
    [Serializable]
     class Ticket : IPrintable
    {
        /// <summary>
        /// 放映场次
        /// </summary>
        private ScheduleItem scheduleItem;

        public ScheduleItem ScheduleItem
        {
            get { return scheduleItem; }
            set { scheduleItem = value; }
        }

        /// <summary>
        /// 所属座位对象
        /// </summary>
        private Seat seat;

        public Seat Seat
        {
            get { return seat; }
            set { seat = value; }
        }

        /// <summary>
        /// 票价
        /// </summary>
        private int price = 60;

        public int Price
        {
            get { return price; }
            set { price = value; }
        }

        /// <summary>
        /// 构造函数
        /// </summary>
        public Ticket() { }
        public Ticket(ScheduleItem scheduleItem, Seat seat)
        {
            this.ScheduleItem = scheduleItem;
            this.Seat = seat;
            //this.Price = price;
        }

         /// <summary>
         /// 重载父类抽象方法
         /// </summary>
        virtual public void CalcPrice()
        {
            this.Price = 60;
        }

         /// <summary>
         /// 实现打印接口
         /// </summary>
        #region IPrintable 成员

        virtual 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.Price);
            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 + -