Loading in 2 Seconds...
Loading in 2 Seconds...
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects.
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
Outline19.1 Test-Driving the Microwave Oven Application19.2 Designing the Microwave Oven Application19.3 Adding a New Class to the Project19.4 Initializing Class Objects: Constructors19.5 Properties19.6 Completing the Microwave Oven Application19.7 Controlling Access to Members19.8 Using the Debugger: The Autos and Locals Windows19.9 Wrap-Up
Figure 19.2 Microwave Oven application accepts only four digits.
Figure 19.3 Microwave Oven application with invalid input.
Figure 19.4 Microwave Oven application after invalid input has been entered and the StartButton clicked.
Figure 19.8 Rearranging and commenting the new control declaration.
Figure 19.9 Variable m_strTime contains the user’s input.
When a number is entered, add the number to the input and display the new time19.2 Designing the Microwave Oven Application
Figure 19.10 Typical numeric event handler.
btnClear_Clickresets variables and Label
DisplayTimeformats time information for display
tmrClock_Clickperforms countdown and updates display19.2 Designing the Microwave Oven Application
Figure 19.11 Microwave Oven application’s remaining event handlers.
Figure 19.14 Default class declaration.
Figure 19.15 Time’s instance variables.
Figure 19.23 Second property definition.
Safer to assign data to properties rather than instance variables, because set accessors perform validity checking19.5 Properties
Figure 19.24 Constructor using properties to initialize variables.
Figure 19.25 Declaring variables for second and minute values.
Start timer and turn “light” on to indicate microwave oven is cooking19.6 Completing the Microwave Oven Application
Figure 19.31 Starting the microwave oven countdown.
Figure 19.33 Modifying invalid user input.
Figure 19.34 Display current input.
Figure 19.36 Time’s instance variables are private.
Figure 19.37 FrmMicrowaveOven’s instance variables are private.
Figure 19.38 FrmMicrowaveOven’s methods are private.
Accessing properties of a programmer-defined type
Use the SystemColors.Control property to restore the default background color to the Panel
Declaring a method as private
TheSubstringmethod returns a subset of characters in astring
ThePadLeftmethod appends characters to the beginning of astring
Figure 19.41 MicrowaveOven application with breakpoints added.
Figure 19.42 Empty Autos window.
Figure 19.43 Empty Locals window.
Property types19.8 Using the Debugger: The Autos and Locals Windows
Figure 19.44 Autos window displaying the state of m_objTime.
Figure 19.45 Locals window displaying the state of m_objTime.
Figure 19.46 Autos window displaying changed variables in red.
Figure 19.47 Locals window displaying changed variables in red.
Figure 19.48 Changing the value of a variable in the Autos window.
Figure 19.49 New variables listed in the Autos window.