الاثنين، 7 مارس 2011

quize2 solution


using System;
using System.Collections.Generic;
using System.Text;


namespace quize2
{

class mytime
{

private int hour;
private int minute;
private int second;



public int H {

get { return hour; }

set

{
  if (hour >= 0 && hour <= 24)

{ hour = value; }

else

{ Console.WriteLine("invalid time"); }

}
}// end h pro



public int M

{  get { return minute; }

set

{  if (value >= 0 && value <= 60)

{ minute = value; }

else

{ Console.WriteLine("invalid time entered "); }

}

 
}// end min pro

public int S

{ get { return second; }

set
{
if (value >= 0 && value <= 60)

{ second = value; }

else

{ Console.WriteLine("invalid time entered "); }

}

}// end sec pro


}//end time class



class Program

{  static void Main(string[] args)

{ mytime t = new mytime();

Console.WriteLine("enter hour ,minutes and the seconds");

t.H=int.Parse(Console.ReadLine());

t.M =int.Parse( Console.ReadLine());

t.S = int.Parse(Console.ReadLine());



Console.WriteLine("time is {0}:{1}:{2}\n",t.H, t.M, t.S);

}

}//end main

}


ليست هناك تعليقات:

إرسال تعليق