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

📄 freeticket.cs

📁 北大青鸟ACCP课程S2项目案例2影院售票系统
💻 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 + -