1: // Fig. 8.10: Book.java
2: // Declare an enum type with constructor and explicit instance fields
3: // and accessors for these field
4:
5: public enum Book
6: {
7: // declare constants of enum type
8: JHTP6( "Java How to Program 6e", "2005" ),
9: CHTP4( "C How to Program 4e", "2004" ),
10: IW3HTP3( "Internet & World Wide Web How to Program 3e", "2004" ),
11: CPPHTP4( "C++ How to Program 4e", "2003" ),
12: VBHTP2( "Visual Basic .NET How to Program 2e", "2002" ),
13: CSHARPHTP( "C# How to Program", "2002" );
14:
15: // instance fields
16: private final String title; // book title
17: private final String copyrightYear; // copyright year
18:
19: // enum constructor
20: Book( String bookTitle, String year )
21: {
22: title = bookTitle;
23: copyrightYear = year;
24: } // end enum Book constructor
25:
26: // accessor for field title
27: public String getTitle()
28: {
29: return title;
30: } // end method getTitle
31:
32: // accessor for field copyrightYear
33: public String getCopyrightYear()
34: {
35: return copyrightYear;
36: } // end method getCopyrightYear
37: } // end enum Book
38:
39:
40: /**************************************************************************
41: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
42: * Pearson Education, Inc. All Rights Reserved. *
43: * *
44: * DISCLAIMER: The authors and publisher of this book have used their *
45: * best efforts in preparing the book. These efforts include the *
46: * development, research, and testing of the theories and programs *
47: * to determine their effectiveness. The authors and publisher make *
48: * no warranty of any kind, expressed or implied, with regard to these *
49: * programs or to the documentation contained in these books. The authors *
50: * and publisher shall not be liable in any event for incidental or *
51: * consequential damages in connection with, or arising out of, the *
52: * furnishing, performance, or use of these programs. *
53: *************************************************************************/