"青鸟影院"的最后一部分
来源:互联网 发布:2g和3g网络的显示 编辑:程序博客网 时间:2024/04/29 00:13
//ScheduleItem.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 青鸟影院
{
[Serializable]
/// <summary>
/// 放映场次
/// </summary>
public class ScheduleItem
{
public ScheduleItem() { }
public ScheduleItem(Movie movie,string time)
{
this.Movie = movie;
this.Time = time;
}
//电影
public Movie Movie { get; set; }
//放映时间
public string Time { get; set; }
}
}
//Seat.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
namespace 青鸟影院
{
[Serializable]
/// <summary>
/// 座位类
/// </summary>
public class Seat
{
public Seat() { }
public Seat(string seatNum,Color color)
{
this.SeatNum = seatNum;
this.Color = color;
}
//座位号
public string SeatNum { get; set; }
//颜色
public Color Color { get; set; }
}
}
//StudentTicket.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace 青鸟影院
{
[Serializable]
/// <summary>
/// 学生票
/// </summary>
public class StudentTicket:Ticket
{
public StudentTicket() { }
public StudentTicket(ScheduleItem scheduleItem,Seat seat,double discount):base(scheduleItem,seat)
{
this.Discount = discount;
this.Price = CalcPrice();
}
//折扣
public double Discount { get; set; }
/// <summary>
/// 计算学生票价格
/// </summary>
/// <returns></returns>
public override double CalcPrice()
{
return this.ScheduleItem.Movie.Price * this.Discount /10;
}
/// <summary>
/// 打印学生票
/// </summary>
public override void Print()
{
string path = (this.ScheduleItem.Time + " " + this.Seat.SeatNum).Replace(":", "-") + ".txt";
using (FileStream fs = new FileStream(path, FileMode.Create))
{
using (StreamWriter sw = new StreamWriter(fs, Encoding.Default))
{
sw.WriteLine("*******************************");
sw.WriteLine(" 青鸟影院(学生票) ");
sw.WriteLine("-------------------------------");
sw.WriteLine("电影名:" + ScheduleItem.Movie.MovieName);
sw.WriteLine("时间:" + this.ScheduleItem.Time);
sw.WriteLine("座位号:" + this.Seat.SeatNum);
sw.WriteLine("折扣:"+this.Discount);
sw.WriteLine("价格:" + this.Price);
sw.WriteLine("*******************************");
}
}
}
}
}
//Ticket.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace 青鸟影院
{
[Serializable]
/// <summary>
/// 电影票父类
/// </summary>
public class Ticket
{
public Ticket() { }
public Ticket(ScheduleItem scheduleItem,Seat seat)
{
this.ScheduleItem = scheduleItem;
this.Seat = seat;
this.Price = CalcPrice();
}
//价格
public double Price { get; set; }
//放映场次
public ScheduleItem ScheduleItem { get; set; }
//座位
public Seat Seat { get; set; }
/// <summary>
/// 计算价格
/// </summary>
/// <returns></returns>
public virtual double CalcPrice()
{
return this.ScheduleItem.Movie.Price;
}
/// <summary>
/// 打印电影票
/// </summary>
public virtual void Print()
{
string path = (this.ScheduleItem.Time + " " + this.Seat.SeatNum).Replace(":", "-") + ".txt";
using (FileStream fs = new FileStream(path,FileMode.Create))
{
using (StreamWriter sw = new StreamWriter(fs,Encoding.Default))
{
sw.WriteLine("*******************************");
sw.WriteLine(" 青鸟影院 ");
sw.WriteLine("-------------------------------");
sw.WriteLine("电影名:"+ScheduleItem.Movie.MovieName);
sw.WriteLine("时间:"+this.ScheduleItem.Time);
sw.WriteLine("座位号:"+this.Seat.SeatNum);
sw.WriteLine("价格:"+this.Price);
sw.WriteLine("*******************************");
}
}
}
}
}
//TicketUtil.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace 青鸟影院
{
/// <summary>
/// 创建电影票工具类
/// 使用简单工厂模式创建票
/// </summary>
public class TicketUtil
{
public static Ticket CreateTicket(ScheduleItem item,Seat seat,string customerName,double discount,string type)
{
Ticket ticket = null;
switch (type)
{
case "normal":
ticket = new Ticket(item, seat);
break;
case "free":
ticket = new FreeTicket(customerName, item, seat);
break;
case "student":
ticket = new StudentTicket(item, seat, discount);
break;
}
return ticket;
}
}
}
- "青鸟影院"的最后一部分
- "青鸟影院"三分之一
- "青鸟影院"三分之二
- 青鸟影院售票系统
- 深入.NET 青鸟影院系统
- 青鸟影院售票系统(一)
- 完成了优选程序的最后一部分
- 今天完成了OA的最后一部分
- 手机的push机制 android请看最后一部分androidpn
- textView出现最后一行字体缺少一部分的情况解决办法
- 上海的IMAX影院
- 《JBoss Seam:一个深度集成框架》一文的最后一部分。
- 影院售票座位的设计
- 北大青鸟的问题
- 在青鸟的日子!!
- 简单的青鸟页面
- Frederick Brooks: 计算机科学家的使命是制造工具 II, 翻译连载第5部分,也是最后一部分
- 写完文件之后最好调用fflush,否则有可能fclose之后,发现文件的最后有一部分没有写入完整。
- log4j:ERROR Attempted to append to closed appender named [null].
- 后盾网Laravel 5.2开发实战视频
- ContentProvider ContentResolve
- 网站运营初期,如何有效提高关键词的排名?
- notepad++更改字体大小和颜色
- "青鸟影院"的最后一部分
- 一、大话设计模式中的主要原则与面向对象思想
- markdown语法及插入图片、链接、公式
- spring boot 乱码解决汇总
- 【Zookeeper】源码分析之服务器(一)
- 传智播客PHP项目实战-微信支付接口
- Android 数据存储五种方式使用与总结
- 实验二
- HDU 1695 莫比乌斯反演