Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Denis afonin #62

Open
wants to merge 4 commits into
base: Denis_Afonin
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions CourseApp/Calc.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace CourseApp
{
public class Calculator
{
public double Division(double a, double b)
{
return a / b;
}

public double Sum(double a, double b)
{
return a + b;
}

public double Subtraction(double a, double b)
{
return a - b;
}

public double Multiplying(double a, double b)
{
return a * b;
}
}
}
8 changes: 8 additions & 0 deletions CourseApp/Player/Player1.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>
122 changes: 122 additions & 0 deletions CourseApp/Player/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
using System;

namespace Player1
{
interface IHasInfo
{
void ShowInfo();
}
interface IWeapon : IHasInfo
{
void Fire();
int Damage { get; }
}

interface IThrowingWeapon : IWeapon
{
void Throw();
}
abstract class Weapon : IHasInfo, IWeapon
{
public abstract int Damage { get; }
public abstract void Fire();

public void ShowInfo()
{
Console.WriteLine($"{GetType().Name} Damage: {Damage}");
}

}

class Gun : Weapon
{
public override int Damage => 10;

public override void Fire()
{
Console.WriteLine("Puff");
}
}

class LaserGun : Weapon
{
public override int Damage => 20;

public override void Fire()
{
Console.WriteLine("Phhh");
}
}

class Bow : Weapon
{
public override int Damage => 7;

public override void Fire()
{
Console.WriteLine("Pow");
}
}

class Knife : IThrowingWeapon
{
public int Damage => 7;

public void Fire()
{
Console.WriteLine("Чиркнул ножом");
}

public void ShowInfo()
{
Console.WriteLine("Knife");
}

public void Throw()
{
Console.WriteLine("Бросил нож");
}
}

class Box : IHasInfo
{
public void ShowInfo()
{
Console.WriteLine("is box");
}

}
class Player
{
public void Fire(IWeapon weapon)
{
weapon.Fire();

}

public void CheckInfo(IHasInfo hasInfo)
{
hasInfo.ShowInfo();
}
}

class Program
{
static void Main(string[] args)
{
Player player = new Player();
IWeapon[] inventory = { new Gun(), new LaserGun(), new Bow(), new Knife() };

foreach (var item in inventory)
{
player.CheckInfo(item);
player.Fire(item);
Console.WriteLine();
}
player.CheckInfo(new Box());


}

}
}
76 changes: 71 additions & 5 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,79 @@
namespace CourseApp
{
using System;
using System.Collections.Generic;
using static System.Math;

public class Program
public class CalculateTasks
{
public static void Main(string[] args)
public CalculateTasks(double aValue, double bValue, double startValue, double endValue, double deltaValue)
{
Console.WriteLine($"Hello world");
Console.ReadLine();
AValue = aValue;
BValue = bValue;
StartValue = startValue;
EndValue = endValue;
DeltaValue = deltaValue;
}

public CalculateTasks(List<double> listValues)
{
AValue = listValues[0];
BValue = listValues[1];
StartValue = listValues[2];
EndValue = listValues[3];
DeltaValue = listValues[4];
}

public CalculateTasks(double aValue, double bValue)
{
AValue = aValue;
BValue = bValue;
}

public CalculateTasks(double startValue, double endValue, double deltaValue)
{
StartValue = startValue;
EndValue = endValue;
DeltaValue = deltaValue;
}

public double StartValue { get; set; }

public double EndValue { get; set; }

public double DeltaValue { get; set; }

public double AValue { get; set; }

public double BValue { get; set; }

public List<(double, double)> StartCalculate(List<double> listValue)
{
var list = new List<(double, double)>();
foreach (var x in listValue)
{
var value = CalculateValue(x);
list.Add(value);
}

return list;
}

public List<double> ListValue()
{
var listValue = new List<double>();
for (var x = StartValue; x <= EndValue; x += DeltaValue)
{
listValue.Add(x);
}

return listValue;
}

public (double, double) CalculateValue(double x)
{
var sin = Asin(Pow(x, AValue));
var cos = Acos(Pow(x, BValue));
return (x, sin + cos);
}
}
}
48 changes: 48 additions & 0 deletions testInterface/Example.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;

namespace testInterface

{

class ConsoleDateProcessor : IDateProcessor
{
void IDateProcessor.ProcessorDate(IDataProvider dateProvider)
{
Console.WriteLine(dateProvider.GetDate());
}
}

class DbDateProvider : IDataProvider
{
public string GetDate()
{
return "Данные из БД";
}
}

class FileProvider : IDataProvider
{
public string GetDate()
{
return "Данные из файла";
}
}

class APIDataProvider : IDataProvider
{
public string GetDate()
{
return "Данные из API";
}
}
class Example
{
static void Main(string[] args)
{
IDateProcessor dateProcessor = new ConsoleDateProcessor();
dateProcessor.ProcessorDate(new DbDateProvider());
dateProcessor.ProcessorDate(new FileProvider());
dateProcessor.ProcessorDate(new APIDataProvider());
}
}
}
19 changes: 19 additions & 0 deletions testInterface/Interface1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace InterfaceTesting
{
interface IDataProvider
{
string GetDate();

}

interface IDateProcessor
{
void ProcessorDate(IDataProvider dateProvider);
}
}
8 changes: 8 additions & 0 deletions testInterface/InterfaceTesting.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

</Project>