using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace 影院售票系统
{
/// <summary>
/// 保存影院的座位信息
/// </summary>
public class Seat
{
public Seat() { }
public Seat(string seatNum,Color color)
{
this.SeatNum = seatNum;
this.Color = color;
}
private string _seatNum;
/// <summary>
/// 座位号
/// </summary>
public string SeatNum
{
get { return _seatNum; }
set { _seatNum = value; }
}
private Color _color;
/// <summary>
/// 座位卖出状态颜色
/// </summary>
public Color Color
{
get { return _color; }
set { _color = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 影院售票系统
{
/// <summary>
/// 电影类
/// </summary>
public class Movie
{
private string _movieName;
/// <summary>
/// 电影名
/// </summary>
public string MovieName
{
get { return _movieName; }
set { _movieName = value; }
}
private string _poster;
/// <summary>
/// 海报图片名
/// </summary>
public string Poster
{
get { return _poster; }
set { _poster = value; }
}
private string _director;
/// <summary>
/// 导演名
/// </summary>
public string Director
{
get { return _director; }
set { _director = value; }
}
private string _actor;
/// <summary>
/// 主演
/// </summary>
public string Actor
{
get { return _actor; }
set { _actor = value; }
}
private int _price;
/// <summary>
/// 定价
/// </summary>
public int Price
{
get { return _price; }
set { _price = value; }
}
/// <summary>
/// 电影类型
/// </summary>
public MovieType MovieType { get; set; }
}
/// <summary>
/// 电影类型,1喜剧2战争3爱情
/// </summary>
public enum MovieType
{
/// <summary>
/// 动作片
/// </summary>
Action = 0,
/// <summary>
/// 战争片
/// </summary>
War = 1,
/// <summary>
/// 爱情片
/// </summary>
Comedy = 2
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace 影院售票系统
{
/// <summary>
/// 电影票父类
/// </summary>
public class Ticket
{
public Ticket() { }
public Ticket(ScheduleItem sch,Seat seat)
{
this.ScheduItem = sch;
this.Seat = seat;
}
private Seat _seat = new Seat();
/// <summary>
/// 所属座位
/// </summary>
public Seat Seat
{
get { return _seat; }
set { _seat = value; }
}
private int _price;
/// <summary>
/// 票价
/// </summary>
public int Price
{
get { return _price; }
set { _price = value; }
}
/// <summary>
/// 放映场次
/// </summary>
public ScheduleItem ScheduItem { get; set; }
/// <summary>
/// 计算票价
/// </summary>
public virtual void CalcPrice()
{
this.Price = ScheduItem.Movie.Price;
}
/// <summary>
/// 打印售票信息
/// </summary>
public virtual void Print()
{
string info = string.Format("************************************************\n\t青鸟影院\n------------------------------------------------\n电影名:\t{0}\n时间:\t{1}\n座位号:\t{2}\n价格:\t{3}\n************************************************", this.ScheduItem.Movie.MovieName, this.ScheduItem.Time, this.Seat.SeatNum, this.Price);
MessageBox.Show(info);
//存到文件中
string fileName = this.ScheduItem.Time.Replace(":", "-")+" "+this.Seat.SeatNum+".txt";
FileStream fs = new FileStream(fileName,FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write(info);
sw.Close();
fs.Close();
}
/// <summary>
/// 显示当前售票信息
/// </summary>
public virtual void Show()
{
string info = string.Format("已售出!\n普通票!");
MessageBox.Show(info);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace 影院售票系统
{
/// <summary>
/// 学生票
/// </summary>
public class StudentTicket : Ticket
{
public StudentTicket() { }
public StudentTicket(ScheduleItem sch, Seat seat, int discount)
: base(sch, seat)
{
this.Discount = discount;
}
private int _discount;
/// <summary>
/// 学生票的折扣
/// </summary>
public int Discount
{
get { return _discount; }
set { _discount = value; }
}
/// <summary>
/// 计算学生票价
/// </summary>
public override void CalcPrice()
{
this.Price =this.ScheduItem.Movie.Price* Discount / 10;
}
/// <summary>
/// 打印学生票的售票信息
/// </summary>
public override void Print()
{
string info = string.Format("************************************************\n\t青鸟影院(学生)\n------------------------------------------------\n电影名:\t{0}\n时间:\t{1}\n座位号:\t{2}\n价格:\t{3}\n************************************************", this.ScheduItem.Movie.MovieName, this.ScheduItem.Time, this.Seat.SeatNum, this.Price);
MessageBox.Show(info);
//存到文件中
string fileName = this.ScheduItem.Time.Replace(":", "-") + " " + this.Seat.SeatNum + ".txt";
FileStream fs = new FileStream(fileName, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write(info);
sw.Close();
fs.Close();
}
/// <summary>
/// 显示当前售出票信息
/// </summary>
public override void Show()
{
string info = string.Format("已售出!\n{0}折学生票!",this.Discount);
MessageBox.Show(info);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace 影院售票系统
{
/// <summary>
/// 赠票
/// </summary>
public class FreeTicket:Ticket
{
public FreeTicket() { }
public FreeTicket(ScheduleItem sch,Seat seat,string name)
{
this.Seat = seat;
this.CustomerName = name;
this.ScheduItem = sch;
}
private string _customerName;
/// <summary>
/// 获得赠票者的名字
/// </summary>
public string CustomerName
{
get { return _customerName; }
set { _customerName = value; }
}
/// <summary>
/// 计算票价
/// </summary>
public override void CalcPrice()
{
this.Price = 0;
}
/// <summary>
/// 打印售票信息
/// </summary>
public override void Print()
{
string info = string.Format("************************************************\n\t青鸟影院(赠票)\n------------------------------------------------\n电影名:\t{0}\n时间:\t{1}\n座位号:\t{2}\n姓名:\t{3}\n************************************************", this.ScheduItem.Movie.MovieName, this.ScheduItem.Time, this.Seat.SeatNum, this.CustomerName);
MessageBox.Show(info);
//存到文件中
string fileName = this.ScheduItem.Time.Replace(":", "-") + " " + this.Seat.SeatNum + ".txt";
FileStream fs = new FileStream(fileName, FileMode.Create);
StreamWriter sw = new StreamWriter(fs);
sw.Write(info);
sw.Close();
fs.Close();
}
/// <summary>
/// 显示当前售出票信息
/// </summary>
public override void Show()
{
MessageBox.Show("已售出!\n赠票!");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 影院售票系统
{
/// <summary>
/// 影院每天计划放映的场次,保存每场电影的信息
/// </summary>
public class ScheduleItem
{
private string _time;
/// <summary>
/// 放映时间
/// </summary>
public string Time
{
get { return _time; }
set { _time = value; }
}
private Movie _movie = new Movie();
/// <summary>
/// 本场放映的电影
/// </summary>
public Movie Movie
{
get { return _movie; }
set { _movie = value; }
}
private List<Ticket> _soldTickets=new List<Ticket>();
private Dictionary<string, Seat> _seats=new Dictionary<string,Seat>();
/// <summary>
/// 本场次的座位状态
/// </summary>
public Dictionary<string, Seat> Seats
{
get { return _seats; }
set { _seats = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace 影院售票系统
{
/// <summary>
/// 放映计划类,保存影院当天的放映计划集合
/// </summary>
public class Schedule
{
/// <summary>
/// 放映场次
/// </summary>
public Dictionary<string, ScheduleItem> Items = new Dictionary<string, ScheduleItem>();
/// <summary>
/// 读取XML文件获取放映计划集合
/// </summary>
public void LoadItems()
{
Items.Clear();
XmlDocument xml = new XmlDocument();
xml.Load("ShowList.xml");
XmlElement root = xml.DocumentElement;
foreach (XmlNode item in root.ChildNodes)
{
Movie movie = new Movie();
movie.MovieName = item["Name"].InnerText;
movie.Poster = item["Poster"].InnerText;
movie.Director = item["Director"].InnerText;
movie.Actor = item["Actor"].InnerText;
switch (item["Type"].InnerText)
{
case "Action":
movie.MovieType = MovieType.Action;
break;
case "War":
movie.MovieType = MovieType.War;
break;
case "Comedy":
movie.MovieType = MovieType.Comedy;
break;
}
movie.Price = Convert.ToInt32(item["Price"].InnerText);
if (item["Schedule"].HasChildNodes)
{
foreach (XmlNode item2 in item["Schedule"].ChildNodes)
{
ScheduleItem schItem = new ScheduleItem();
schItem.Time = item2.InnerText;
schItem.Movie = movie;
Items.Add(schItem.Time, schItem);
}
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 影院售票系统
{
/// <summary>
/// 影院类
/// </summary>
public class Cinema
{
private Dictionary<string, Seat> _seats = new Dictionary<string, Seat>();
/// <summary>
/// 座位集合
/// </summary>
public Dictionary<string, Seat> Seats
{
get { return _seats; }
set { _seats = value; }
}
private Schedule _schedule = new Schedule();
/// <summary>
/// 放映计划
/// </summary>
public Schedule Schedule
{
get { return _schedule; }
set { _schedule = value; }
}
private List<Ticket> _soldTickets=new List<Ticket>();
/// <summary>
/// 已经售出的票
/// </summary>
public List<Ticket> SoldTickets
{
get { return _soldTickets; }
set { _soldTickets = value; }
}
/// <summary>
/// 保存售票信息到文件中
/// </summary>
public void Save()
{
//Save和Load的代码在窗体的代码实现了
}
/// <summary>
/// 从文件中读取售票信息
/// </summary>
public void Load() { }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 影院售票系统
{
/// <summary>
/// 工具类
/// </summary>
public class TicketUtil
{
/// <summary>
/// 创建电影票
/// </summary>
/// <returns></returns>
public static Ticket CreateTicket(ScheduleItem sch,Seat seat,int discount,string customerName,string type)
{
Ticket ticket=null;
switch (type)
{
case "StudentTicket":
ticket = new StudentTicket(sch,seat,discount);
break;
case "FreeTicket":
ticket = new FreeTicket(sch,seat,customerName);
break;
default:
ticket = new Ticket(sch,seat);
break;
}
return ticket;
}
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有