Skip to content

Lectures #16

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

Open
wants to merge 6 commits into
base: master
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
21 changes: 21 additions & 0 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace CourseApp.Tests
{
using Phones;
using Xunit;

public class DemoTest
Expand All @@ -9,5 +10,25 @@ public void Test1()
{
Assert.True(true);
}

[Fact]
public void TestCreatePhone()
{
var phone = new LandlinePhone("123", "Name", -1);
Assert.Equal("Name", phone.Name);
Assert.Equal(1880, phone.Year);
}

[Theory]
[InlineData(5, 12, 12)]
[InlineData(5, -1, 5)]
[InlineData(5, 20, 5)]
public void TestDiagonal(int initial, int change, int expected)
{
var phone = new CellPhone("123", "Name", initial);
Assert.Equal(5, phone.Diagonal);
phone.Diagonal = change;
Assert.Equal(expected, phone.Diagonal);
}
}
}
38 changes: 0 additions & 38 deletions CourseApp/Phone.cs

This file was deleted.

21 changes: 21 additions & 0 deletions CourseApp/Phones/AndroidPhone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace Phones
{
public class AndroidPhone<T> : SmartPhone<T>
where T : IAndroidApp
{
public AndroidPhone()
: base("+70000000", "Pixel", 2022)
{
}

public AndroidPhone(string number, string name, int diagonal)
: base(number, name, diagonal)
{
}

public override void AddApp(T app)
{
base.AddApp(app);
}
}
}
16 changes: 16 additions & 0 deletions CourseApp/Phones/Application.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Phones
{
public abstract class Application : IApplication
{
public Application(string name)
{
this.Name = name;
}

public string Name { get; set; }

public abstract void InstallApp();

public abstract void RunApp();
}
}
70 changes: 70 additions & 0 deletions CourseApp/Phones/CellPhone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
namespace Phones
{
using System;

public class CellPhone : Phone
{
private float diagonal;

public CellPhone()
: base("+70000000", "nokia", 2)
{
Console.WriteLine("Cell phone without params");
}

public CellPhone(string number, string name, int diagonal)
: base(number, name, 2000)
{
this.Diagonal = diagonal;
Console.WriteLine("Cell phone with params");
}

public float Diagonal
{
get
{
return diagonal;
}

set
{
if (value > 0 && value < 20)
{
this.diagonal = value;
}
}
}

public string TrackName { get; set; }

public void DeclineCall()
{
Console.WriteLine("Decline Call");
}

public void GetMessage()
{
Console.WriteLine("Getting text message");
}

public void SendMessage()
{
Console.WriteLine("Sending message");
}

public void PlayMusic()
{
Console.WriteLine($"Сейчас играет {TrackName}");
}

public override string ToString()
{
return $"Сотовый телефон {Name} номер:{Number}, произведен {Year}";
}

public override string Display()
{
return this.ToString();
}
}
}
27 changes: 27 additions & 0 deletions CourseApp/Phones/FaceTime.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Phones
{
using System;

public class FaceTime : Application, IIOsApp
{
public FaceTime(string name)
: base(name)
{
}

public void CheckWallet()
{
Console.WriteLine("Checking FaceTimeApp");
}

public override void InstallApp()
{
Console.WriteLine("Installing FaceTime");
}

public override void RunApp()
{
Console.WriteLine("Running FaceTime");
}
}
}
7 changes: 7 additions & 0 deletions CourseApp/Phones/IAndroidApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Phones
{
public interface IAndroidApp : IApplication
{
public void CheckGoogle();
}
}
9 changes: 9 additions & 0 deletions CourseApp/Phones/IApplication.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Phones
{
public interface IApplication
{
public void InstallApp();

public void RunApp();
}
}
7 changes: 7 additions & 0 deletions CourseApp/Phones/IDisplayable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Phones
{
public interface IDisplayable
{
public string Display();
}
}
7 changes: 7 additions & 0 deletions CourseApp/Phones/IIosApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace Phones
{
public interface IIOsApp : IApplication
{
public void CheckWallet();
}
}
16 changes: 16 additions & 0 deletions CourseApp/Phones/IOSPhone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace Phones
{
public class IOSPhone<T> : SmartPhone<T>
where T : IIOsApp
{
public IOSPhone()
: this("+70000000", "Pixel", 2022)
{
}

public IOSPhone(string number, string name, int diagonal)
: base(number, name, diagonal)
{
}
}
}
27 changes: 27 additions & 0 deletions CourseApp/Phones/KeepApp.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
namespace Phones
{
using System;

public class KeepApp : Application, IAndroidApp
{
public KeepApp(string name)
: base(name)
{
}

public void CheckGoogle()
{
Console.WriteLine("Big brother watching you!");
}

public override void InstallApp()
{
Console.WriteLine("Installing Keep");
}

public override void RunApp()
{
Console.WriteLine("Running Keep");
}
}
}
25 changes: 25 additions & 0 deletions CourseApp/Phones/LandlinePhone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Phones
{
public class LandlinePhone : Phone, IDisplayable
{
public LandlinePhone()
: base("+70000000", "Проводной", 2)
{
}

public LandlinePhone(string number, string name, int year)
: base(number, name, year)
{
}

public override string ToString()
{
return $"Проводной телефон {Name} номер:{Number}, произведен {Year}";
}

public override string Display()
{
return this.ToString();
}
}
}
10 changes: 10 additions & 0 deletions CourseApp/Phones/Pen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Phones
{
public class Pen : IDisplayable
{
public string Display()
{
return "Smart pen";
}
}
}
Loading