tailieunhanh - Microsoft Visual C# 2010 Step by Step (P12)
Tham khảo sách 'microsoft visual c# 2010 step by step (p12)', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 520 Part IV Working with Windows Applications Add properties to validate the privilege level and number of tickets 1. Switch to the Code and Text Editor window displaying the file. 2. Add the PrivilegeLevel enumeration shown next in bold type to the file above the TicketOrder class enum PrivilegeLevel Standard Premium Executive PremiumExecutive class TicketOrder You will use this enumeration to specify the type of the PrivilegeLevel property in the TicketOrder class. 3. Add the privilegeLevel and numberOfTickets private fields to the TicketOrder class as shown in bold type here class TicketOrder private string eventName private string customerReference private PrivilegeLevel privilegeLevel private short numberOfTickets 4. Add the private checkPrivilegeAndNumberOfTickets Boolean method to the TicketOrder class as shown in bold type here class TicketOrder private bool checkPrivilegeAndNumberOfTickets PrivilegeLevel proposedPrivilegeLevel short proposedNumberOfTickets bool retVal false switch proposedPrivilegeLevel case retVal proposedNumberOfTickets 2 break case retVal proposedNumberOfTickets 4 break case retVal proposedNumberOfTickets 8 break Chapter 24 Performing Validation 521 case retVal proposedNumberOfTickets 10 break return retVal This method examines the values in the proposedPrivilegeLevel and proposedNumberOfTickets parameters and tests them for consistency according to the business rules described earlier in this chapter. If the values are consistent this method returns true otherwise it returns false. 5. Add the public PrivilegeLevel and NumberOfTickets properties shown next in bold type to the TicketOrder class. Note that the type of the PrivilegeLevel property is the PrivilegeLevel enumeration class Customer public PrivilegeLevel PrivilegeLevel get return set value if .
đang nạp các trang xem trước