O'Reilly logo

Visual C#® 2012: How to Program, Fifth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

10.2. Time Class Case Study

Time1 Class Declaration

Our first example consists of classes Time1 (Fig. 10.1) and Time1Test (Fig. 10.2). Class Time1 represents the time of day. Class Time1Test’s Main method creates an object of class Time1 and invokes its methods. The output of this app appears in Fig. 10.2. [Note: C# has the type DateTime for date and time manipulations. Our time examples are for demonstration purposes—you do not need to create your own types for dates and times.]

 1   // Fig. 10.1: Time1.cs  2   // Time1 class declaration maintains the time in 24-hour format.  3   using System; // namespace containing ArgumentOutOfRangeException  4  5   public class Time1  6   {  7      private int hour; // 0 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required