R
Robert Blackwell
I don't understand this.
Example 8-4 declares a constructor for the Time class that accepts a single
argument, and object of type DateTime. DateTime is a type provided by the
..NET Framework Class Library.
it looks to me as though it's passing 6 single arguments all of type
int...it'd be crazy to believe that this is a typo, so please help me
understand
using System;
public class Time
{
// private member variables
int year;
int month;
int date;
int hour;
int minute;
int second;
// public method
public void DisplayCurrentTime()
{
System.Console.WriteLine("{0}/{1}/{2} {3}:{4}:{5}",
month, date, year, hour, minute, second);
}
// constructor
public Time(int theYear, int theMonth, int theDate,
int theHour, int theMinute, int theSecond)
{
year = theYear;
month = theMonth;
date = theDate;
hour = theHour;
minute = theMinute;
second = theSecond;
}
}
public class Tester
{
static void Main()
{
Time timeObject = new Time(2005,3,25,9,35,20);
timeObject.DisplayCurrentTime();
}
}
Example 8-4 declares a constructor for the Time class that accepts a single
argument, and object of type DateTime. DateTime is a type provided by the
..NET Framework Class Library.
it looks to me as though it's passing 6 single arguments all of type
int...it'd be crazy to believe that this is a typo, so please help me
understand
using System;
public class Time
{
// private member variables
int year;
int month;
int date;
int hour;
int minute;
int second;
// public method
public void DisplayCurrentTime()
{
System.Console.WriteLine("{0}/{1}/{2} {3}:{4}:{5}",
month, date, year, hour, minute, second);
}
// constructor
public Time(int theYear, int theMonth, int theDate,
int theHour, int theMinute, int theSecond)
{
year = theYear;
month = theMonth;
date = theDate;
hour = theHour;
minute = theMinute;
second = theSecond;
}
}
public class Tester
{
static void Main()
{
Time timeObject = new Time(2005,3,25,9,35,20);
timeObject.DisplayCurrentTime();
}
}