Architecture and functions of qingbird Cinema (I): Functions of qingbird cinema framework

Source: Internet
Author: User

Architecture and functions of qingbird Cinema (I): Functions of qingbird cinema framework

Functions of cinema ticketing system:

1. The cinema updates the screening list every day. The system supports real-time viewing, including the screening time and movie overview.

2. Cinema offers three types of cinema tickets: normal pass, complimentary pass, and student pass (free pass, student pass discounts to varying degrees)

3. allow the user to view the sale status of a specified seat

4. Support for ticket purchase and allow users to select seats

5. You can select the venue, movie ticket type and free seats to purchase tickets, and print movie tickets.

6. The system can save sales information and allow recovery.

Skills covered:

1. Ability to analyze system functions and extract objects and Classes

2. The class graph is used to understand the class relationship.

3. Classes are constructed using attributes and methods.

4. Generic sets are used.

5. Enumeration will be used

6. Object-oriented ideas, TreeView, XML reading, File stream, and generic set

7. Read the XML file: Read the XML file cyclically, store the display list to the set, traverse the set, and fill the display list to the TreeView control.

8. The ticket information will be saved and restored using the file: the ticket information will be saved to the file, and the ticket information will be read from the file to continue selling tickets.

System development steps:

1. clarify requirements

2. Design

3. Create a project

4. Determine the encoding sequence:

01: Main form

02: view the new screening list

03: View Movie Introduction

04: view the ticket price

05: view the auditorium seats

06: purchase tickets and print movie tickets

07: continue purchasing tickets

5. Test

Interface interaction design principles

1. Aesthetics

2. ease of use

3. friendliness

System class:

Class diagram:

1. Seat: stores the cinema Seat information. The main attributes are as follows:

Seat Number (SeatNum): string type

Sales Color: System. Drawing. Color type

2. Movie: Movie

Movie name (MovieName): string type

Poster image path (Poster): string type

Director name (Director): string type

Actor: string type

Movie type (MovieType): MovieType custom Enumeration type

Price: int type

3. Ticket: the parent category of a movie Ticket. It stores the information about the movie Ticket.

Show SESSION (ScheduleItem): ScheduleItem custom class

Seat object (Seat): custom Seat type

Price: int type

CalcPrice ()

Print ()

Show ()

4. StudentTicket: Child class of the student Ticket, inheriting the parent class Ticket

Student Discount (Discount): int type

Override the parent class calculation fare CalcPrice

Overwrite Print () of the ticket information printed by the parent class ()

Override the Show () method for displaying the current invoice information of the parent class.

5. FreeTicket: coupon subclass that inherits the parent class Ticket

Name attribute of the winner (CustomerName): string type

Override the parent class to calculate the fare CalcPrice ()

Overwrite the parent class to Print the ticket information Print ()

Overwrite the parent class to display the current issue information Show ()

6. ScheduleItem

Projection Time attribute (Time): string type

Movie screening attribute (Movie): Custom Movie type

7. Schedule: screening plan class

Projection properties (Items): Custom generic set Dictionary <string, ScheduleItem>

Obtain the LoadItems () method of the projection plan set by reading XML files

8. Cinema: Cinema class, save the screening plan and seat class

Seat: Custom generic set Dictionary <string, Seat>

Display Plan Schedule: Schedule custom type

SoldTicket: Custom generic collection List <Ticket>

Save () and Load () methods for saving and reading ticket sales information

9. MovieType (Enumeration type)

10. TicketUtil: tool class

Now the framework is ready.

Focus on code:

1. To put data on the TreeView, you must parse the XML file.

We parse the XML file in the projection time class:

As follows:

Public void LoadItems () {if (Items = null) {Items = new Dictionary <string, ScheduleItem> () ;}// clear Items. clear (); XmlDocument doc = new XmlDocument (); doc. load ("ShowList. xml "); XmlNode root = doc. documentElement; // The intermediate variable string movieName = null; string playBill = null; string director = null; string actor = null; string movieType = null; string price = null; foreach (XmlNode item in root. childNodes) {if (item. name = "Movie") {foreach (XmlNode child in item. childNodes) {switch (child. name) {case "Name": movieName = child. innerText; break; case "Poster": playBill = child. innerText; break; case "Director": director = child. innerText; break; case "Actor": actor = child. innerText; break; case "Type": movieType = child. innerText; break; case "Price": price = child. innerText; break; case "Schedule": foreach (XmlNode scheduleNode in child. childNodes) {ScheduleItem scheduleItem = new ScheduleItem (); scheduleItem. time = scheduleNode. innerText; scheduleItem. movie. movieName = movieName; scheduleItem. movie. poster = playBill; scheduleItem. movie. actor = actor; scheduleItem. movie. director = director; scheduleItem. movie. movieType = (MovieType) Enum. parse (typeof (MovieType), movieType); scheduleItem. movie. price = int. parse (price); Items. add (scheduleItem. time, scheduleItem) ;}break ;}}}

 

2. Bind data to the TreeView control:

The Code is as follows:

Public void InitTreeView () {// Abstract: // disable repainting of any tree view. Tvlist. beginUpdate (); tvlist. nodes. clear (); // load the xml file // string movieName = null; TreeNode movieNode = null; foreach (ScheduleItem item in cinema. schedule. items. values) {if (movieNode = null | movieNode. text! = Item. movie. movieName) {movieNode = new TreeNode (item. movie. movieName); tvlist. nodes. add (movieNode);} movieNode. nodes. add (item. time) ;}//// Abstract: // enable the re-painting of the Tree View. Tvlist. EndUpdate ();}

3. In the AfterSelect event, bind the data to the control on the right to display information.

/// View the introduction of the movie private void tvlist_AfterSelect (object sender, TreeViewEventArgs e) {// switch back to the normal ticket and clear the remaining information txtGive. text = ""; cboStudentDivPrice. the Text = ""; // GetKey () method is to get the GetKey () Time of the selected session; // display the detailed information of the movie to lblMovieName. text = cinema. schedule. items [key]. movie. movieName; lblDirector. text = cinema. schedule. items [key]. movie. director; lblActor. text = cinema. schedule. items [key]. movie. actor; lblBasePrice. text = cinema. schedule. items [key]. movie. price. toString (); lblPlayTime. text = cinema. schedule. items [key]. time; lblMovieType. text = cinema. schedule. items [key]. movie. movieType. toString (); picMovie. image = Image. fromFile (cinema. schedule. items [key]. movie. poster); lblGoodPrice. text = "";

This completes the first step.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.