Added Toto example
This commit is contained in:
90
HF/20231206HF/feladat2.cs
Normal file
90
HF/20231206HF/feladat2.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConsoleApp1
|
||||
{
|
||||
public class Kor
|
||||
{
|
||||
public Kor() {
|
||||
Console.WriteLine("Add meg az x koordinátát.");
|
||||
X = Convert.ToDouble(Console.ReadLine());
|
||||
Console.WriteLine("Add meg az y koordinátát.");
|
||||
Y = Convert.ToDouble(Console.ReadLine());
|
||||
Console.WriteLine("Add meg a kör sugarát.");
|
||||
R = Convert.ToDouble(Console.ReadLine());
|
||||
}
|
||||
|
||||
public Kor(double x, double y, double r)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
R = r;
|
||||
}
|
||||
|
||||
private double x ;
|
||||
private double y;
|
||||
private double r;
|
||||
|
||||
public double X {
|
||||
get { return x; }
|
||||
set { this.x = value; }
|
||||
}
|
||||
public double Y
|
||||
{
|
||||
get { return y; }
|
||||
set { this.y = value; }
|
||||
}
|
||||
public double R
|
||||
{
|
||||
get { return r; }
|
||||
set { this.r = value; }
|
||||
}
|
||||
|
||||
public double Terulet()
|
||||
{
|
||||
return Math.Pow(R, 2) * Math.PI;
|
||||
}
|
||||
|
||||
public double Kerulet()
|
||||
{
|
||||
return 2 * R * Math.PI;
|
||||
}
|
||||
|
||||
public void Sugarcsere(double rad)
|
||||
{
|
||||
R = rad;
|
||||
}
|
||||
|
||||
public void Sugarcsere()
|
||||
{
|
||||
Console.WriteLine("Add meg az új sugarat!");
|
||||
double r = Convert.ToDouble(Console.ReadLine());
|
||||
R = r;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
Kor kor = new Kor();
|
||||
Kor kor1 = new Kor(0, 0, 1);
|
||||
|
||||
Console.WriteLine(kor.Kerulet());
|
||||
Console.WriteLine(kor.Terulet());
|
||||
Console.WriteLine(kor.R);
|
||||
kor.Sugarcsere();
|
||||
Console.WriteLine(kor.R);
|
||||
|
||||
Console.WriteLine(kor1.Kerulet());
|
||||
Console.WriteLine(kor1.Terulet());
|
||||
kor1.Sugarcsere(2);
|
||||
Console.WriteLine(kor1.R);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user