Advertisement
cupsamada

c#

Jun 25th, 2020
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. namespace lectia1
  2. {
  3. class Timp
  4. {
  5. public int ora;
  6. public int min;
  7. public int sec;
  8. public Timp()
  9. {
  10. ora = 12;
  11. min = 23;
  12. sec = 37;
  13. }
  14. public Numar(int x)
  15. {
  16. ora = x;
  17. min = y;
  18. sec = z;
  19. }
  20. public Boolean EsteFix()
  21. {
  22. if(min == 0 && sec == 0)
  23. return true;
  24. else
  25. return false;
  26. }
  27.  
  28. }
  29.  
  30.  
  31. class Numar //clasa
  32. {
  33.  
  34.  
  35. public int valoare;//data membru
  36.  
  37.  
  38.  
  39. public Numar()//constructor
  40. {
  41. valoare = 5;
  42. }
  43. public Boolean Par()//metode
  44. {
  45. if(valoare%2 ==0)
  46. return true;
  47. else
  48. return false;
  49. }
  50. public Numar(int x)//constructor
  51. {
  52. valoare = x;
  53. }
  54. }
  55. class Program
  56. {
  57. static void Main(string[] args)
  58. {
  59. Timp x = new Timp();
  60. //x.valoare = 5;
  61. if(x.Par())
  62. Console.writeline(x.valoare+" par");
  63. else
  64. Console.WriteLine("impar");
  65. Console.Read();
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement