Best web design - Chapter 8 Object-Based Programming 331 95 96 set
Chapter 8 Object-Based Programming 331 95 96 set 97 { 98 second = ( ( value >=0 && value < 60 ) ?value : 0 ); 99 } 100 101 } // end property Second 102 103 // convert time to universal-time (24 hour) format string 104 public string ToUniversalString() 105 { 106 return String.Format( 107 "{0:D2}:{1:D2}:{2:D2}", Hour, Minute, Second ); 108 } 109 110 // convert time to standard-time (12 hour) format string 111 public string ToStandardString() 112 { 113 return String.Format( "{0}:{1:D2}:{2:D2} {3}", 114 ( ( Hour == 12 || Hour == 0 ) ? 12 : Hour % 12 ), 115 Minute, Second, ( Hour < 12 ? "AM" : "PM" ) ); 116 } 117 118 } // end class Time3 119 } Fig. 8.17 Fig. 8.17Fig. 8.FiFi17g. 8.17g. 8.17Assembly TimeLibrarycontains class Time3. (Part 3 of 3.) We now describe, step-by-step, how to create the class library TimeLibrary containing class Time3: 1. Create a class library project. From the File menu, choose option New, followed by Project . In the New Project dialog, ensure that C# Projects is selected in the Project Types section and click Class Library. Name the project TimeLibrary and choose the directory in which you would like to store the project. A simple class library will be created, as shown in Fig. 8.18. There are two important points to note about the generated code. The first is that the class does not contain a Mainmethod. This indicates that the class in the class library cannot be used to begin the execution of an application. This class is designed to be used by other programs. Also notice that Class1 is created as a public class. If another project uses this library, only the library s publicclasses are accessible. We created class Time3 as public for this purpose (line 9 of Fig. 8.17) by renaming the class Class1 (created by Visual Studio as part of the project) to Time3. In the Solution Explorer, we also renamed the Class1.csfile as Time3.cs. 2. Add the code for class Time3. Delete the code for the Class1constructor. Then, copy the remainder of the Time3 code (lines 11 116) from Fig. 8.17 (you can find this file in the examples on the CD that accompanies this book) and paste the code in the body of the class definition shown in Fig. 8.18. 3. Compile the code. From the Build menu, choose option Build Solution. The code should compile successfully. Remember that this code cannot be executed
We recommend high quality webhost to host and run your jsp application: christian web host services.