add class and some OOP

This commit is contained in:
2022-06-29 22:24:01 +03:00
parent 3b87d0c682
commit fa0034a6a8
10 changed files with 161 additions and 94 deletions
+72
View File
@@ -0,0 +1,72 @@
namespace pr
{
class HomeWork
{
public void First_task()
{
Console.Write("Input first number: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Input second number: ");
int b = Convert.ToInt32(Console.ReadLine());
if (a > b)
Console.WriteLine("Max is: " + a);
else
Console.WriteLine("Max is: " + b);
}
public void Second_task()
{
int max;
Console.Write("Input first number: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Input second number: ");
int b = Convert.ToInt32(Console.ReadLine());
Console.Write("Input third number: ");
int c = Convert.ToInt32(Console.ReadLine());
/// use standart System.Math
// Console.WriteLine("Max is: " + Math.Max(a, Math.Max(b, c)));
max = b > a ? b : a;
max = max > c ? max : c;
Console.WriteLine("Max is: " + max);
}
public void Third_task()
{
Console.Write("Input number for check even: ");
int inputNumber = Convert.ToInt32(Console.ReadLine());
if (inputNumber % 2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Not even");
}
public void Foth_task()
{
int current = 1;
Console.Write("Input number: ");
int numberTask4 = Convert.ToInt32(Console.ReadLine());
while (current <= numberTask4)
{
if (current % 2 == 0)
Console.WriteLine(current);
current++;
}
}
}
}
-93
View File
@@ -1,93 +0,0 @@
Main();
static void Main(){
Console.Write("Wich task: ");
int taskNumver = Convert.ToInt32(Console.ReadLine());
switch (taskNumver)
{
case 1:
First_task();
break;
case 2:
Second_task();
break;
case 3:
Third_task();
break;
case 4:
Foth_task();
break;
default:
Console.WriteLine("Wrong task");
break;
}
}
static void First_task()
{
Console.Write("Input first number: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Input second number: ");
int b = Convert.ToInt32(Console.ReadLine());
if (a > b)
Console.WriteLine("Max is: " + a);
else
Console.WriteLine("Max is: " + b);
}
static void Second_task()
{
int max;
Console.Write("Input first number: ");
int a = Convert.ToInt32(Console.ReadLine());
Console.Write("Input second number: ");
int b = Convert.ToInt32(Console.ReadLine());
Console.Write("Input third number: ");
int c = Convert.ToInt32(Console.ReadLine());
/// use standart System.Math
// Console.WriteLine("Max is: " + Math.Max(a, Math.Max(b, c)));
max = b > a ? b : a;
max = max > c ? max : c;
Console.WriteLine("Max is: " + max);
}
static void Third_task()
{
Console.Write("Input number for check even: ");
int inputNumber = Convert.ToInt32(Console.ReadLine());
if (inputNumber%2 == 0)
Console.WriteLine("Even");
else
Console.WriteLine("Not even");
}
static void Foth_task()
{
int current = 1;
Console.Write("Input number: ");
int numberTask4 = Convert.ToInt32(Console.ReadLine());
while (current<= numberTask4)
{
if (current%2 == 0)
Console.WriteLine(current);
current++;
}
}
+88
View File
@@ -0,0 +1,88 @@
namespace pr;
public class Start
{
static void Main()
{
Console.Write("HW or Practic: ");
int taskNumver = Convert.ToInt32(Console.ReadLine());
switch (taskNumver)
{
case 1:
MyTask();
break;
case 2:
PracticsTask();
break;
}
}
static void MyTask()
{
HomeWork HW = new HomeWork();
Console.Write("Wich task: ");
int taskNumver = Convert.ToInt32(Console.ReadLine());
switch (taskNumver)
{
case 1:
HW.First_task();
break;
case 2:
HW.Second_task();
break;
case 3:
HW.Third_task();
break;
case 4:
HW.Foth_task();
break;
default:
Console.WriteLine("Wrong task");
break;
}
}
static void PracticsTask()
{
Practics pract = new Practics();
Console.Write("Wich task: ");
int taskNumver = Convert.ToInt32(Console.ReadLine());
switch (taskNumver)
{
case 1:
pract.MaxNamber();
break;
case 2:
int task2 = Convert.ToInt32(Console.ReadLine());
pract.Second_task_1(task2);
break;
case 3:
break;
case 4:
break;
default:
Console.WriteLine("Wrong task");
break;
}
}
}
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
4726f62c8aecdfb151956f90c7e130fcb5d3f1d4
1cea4dc6da66272d27938ece339a31c45c8e4364
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.