0

I am trying to build a constructor capable of using the current time from the time function as declared in the C++ standard library ( <ctime> ). This constructor should initialize an object of the Time class. Is what I have below going to work?

I guess I need to download Dev C++ again. It won't finish compiling anything right now.

using System;
namespace ThisTest
{
   public class Time : Object
   {
      private int hour;    
      private int minute;  
      private int second;  
      // constructor
      public Time4( int hour, int minute, int second ) 
      { 
         this.hour = hour;
         this.minute = minute;
         this.second = second;
      }
      
      public string BuildString()
      {
         return "this.ToStandardString(): " + 
            this.ToStandardString() + 
            "\nToStandardString(): " + ToStandardString();
      }
      
      public string ToStandardString()
      {
         return String.Format( "{0}:{1:D2}:{2:D2} {3}",
            ( ( this.hour == 12 || this.hour == 0 ) ? 12 : 
            this.hour % 12 ), this.minute, this.second,
            ( this.hour < 12 ? "am" : "pm" ) );
      }      
   }
3
Contributors
2
Replies
3
Views
11 Years
Discussion Span
Last Post by SpS
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.