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

📄 cinema.cs

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

namespace CinemaTicket
{
    /// <summary>
    /// 电影院类,保存放映计划和座位类
    /// </summary>
    [Serializable]
    class Cinema
    {
        /// <summary>
        /// 座位集合属性
        /// </summary>
        private Dictionary<string, Seat> seats;

        public Dictionary<string, Seat> Seats
        {
            get { return seats; }
            set { seats = value; }
        }

        /// <summary>
        /// 放映计划
        /// </summary>
        private Schedule schedule;

        public Schedule Schedule
        {
            get { return schedule; }
            set { schedule = value; }
        }

        /// <summary>
        /// 已售出电影票的集合
        /// </summary>
        private List<Ticket> soldTickets;

        
        public List<Ticket> SoldTickets
        {
            get { return soldTickets; }
            set { soldTickets = value; }
        }

        public Cinema() { this.Seats = new Dictionary<string, Seat>(); this.SoldTickets = new List<Ticket>(); this.Schedule = new Schedule(); }


        
        /// <summary>
        /// 序列化保存
        /// </summary>
        public void Save()
        {
            //Cinema cinema = new Cinema();
            FileStream fs = new FileStream("profile.bin",FileMode.Create);
            BinaryFormatter bf = new BinaryFormatter();
            bf.Serialize(fs, SoldTickets);
            fs.Close();
        }

        /// <summary>
        /// 序列化读取
        /// </summary>
        public void Load()
        {
            //Cinema cinema = new Cinema();
            FileStream fs = new FileStream("profile.bin", FileMode.Open);
            BinaryFormatter bf = new BinaryFormatter();
            SoldTickets = (List<Ticket>)bf.Deserialize(fs);
            fs.Close();
        }

    }
}

⌨️ 快捷键说明

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