freeticket.cs

来自「影院售票系统,三层架构」· CS 代码 · 共 53 行

CS
53
字号
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace MyCinema
{
    [Serializable]
    public class FreeTicket:Ticket,IPrintable
    {
        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()
        {
            this.Price = 0;
        }

        #region IPrintable 成员

        public override 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.CustomerName);
            sw.WriteLine("***************************");
            sw.Close();
            fs.Close();
        }

        #endregion
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?