freeticket.cs

来自「青鸟影院」· CS 代码 · 共 55 行

CS
55
字号
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 + =
减小字号Ctrl + -
显示快捷键?