Chapter 8 Object-Based Programming (Remote web server) 329 The only difference

Chapter 8 Object-Based Programming 329 The only difference between class Time3in this example and the version in Fig. 8.6 is that we show the namespace, i.e., TimeLibrary, in which Time3is defined. Each class library is defined in a namespacethat contains all the classes in the library. We will demonstrate momentarily how to package class Time3 into TimeLibrary.dll the dynamic link library that we create for reuse in other programs. Programs can load dynamic link libraries at execution time to access common functionality that can be shared among many programs. A dynamic link library represents an assembly. When a project uses a class library, the project must contain a reference to the assembly that defines the class library. 1 // Fig. 8.17: TimeLibrary.cs 2 // Placing class Time3 in an assembly for reuse. 3 4 using System; 5 6 namespace TimeLibrary // specifies namespace for class Time3 7 { 8 // Time3 class definition 9 public class Time3 10 { 11 private int hour; // 0-23 12 private int minute; // 0-59 13 private int second; // 0-59 14 15 // Time3 constructor initializes instance variables to 16 // zero to set default time to midnight 17 public Time3() 18 { 19 SetTime( 0, 0, 0 ); 20 } 21 22 // Time3 constructor: hour supplied, minute and second 23 // defaulted to 0 24 public Time3( int hour ) 25 { 26 SetTime( hour, 0, 0 ); 27 } 28 29 // Time3 constructor: hour and minute supplied, second 30 // defaulted to 0 31 public Time3( int hour, int minute ) 32 { 33 SetTime( hour, minute, 0 ); 34 } 35 36 // Time3 constructor: hour, minute and second supplied 37 public Time3( int hour, int minute, int second ) 38 { 39 SetTime( hour, minute, second ); 40 } 41 Fig. 8.17 Fig. 8.17Fig. 8.FiFi17g. 8.17g. 8.17Assembly TimeLibrarycontains class Time3. (Part 1 of 3.)
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

Leave a Reply