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

Practice #12

Open
wants to merge 2 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
32 changes: 32 additions & 0 deletions CourseApp.Tests/DemoTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,37 @@ public void Test1()
{
Assert.True(true);
}

[Fact]
public void TestDefaultConstructor()
{
var phone = new Phone();
Assert.Equal(1, phone.Version);
Assert.Equal("+000000000", phone.Number);
}

[Fact]
public void TestVersionOk()
{
var phone = new Phone();
phone.Version = 5;
Assert.Equal(5, phone.Version);
}

[Fact]
public void TestBadVersionLessThanZero()
{
var phone = new Phone();
phone.Version = -5;
Assert.Equal(1, phone.Version);
}

[Fact]
public void TestBadVersionGtThan20()
{
var phone = new Phone();
phone.Version = 21;
Assert.Equal(1, phone.Version);
}
}
}
2 changes: 1 addition & 1 deletion CourseApp/CourseApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TreatWarningsAsErrors>True</TreatWarningsAsErrors>
<TreatWarningsAsErrors>False</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
48 changes: 29 additions & 19 deletions CourseApp/Phone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,45 @@ namespace CourseApp

public class Phone
{
private float diaonal;

public Phone(string name, float diagonal)
{
Name = name;
Diagonal = diagonal;
}

public string Name { get; set; }

public float Diagonal
private int version;
public string Number;

public int Version
{
get
get
{
return diaonal;
return version;
}

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

public void Show()
public void AcceptCall()
{
Console.WriteLine("Принимаю звонок");
}
public void CloseCall()
{
Console.WriteLine("Завершаю звонок");
}

public void MakeCall(string phoneNumber)
{
Console.WriteLine($"Звонок на номер {phoneNumber}");
}

public Phone() :this(1, "+000000000")
{}

public Phone(int version, string number)
{
Console.WriteLine($"{Name} with diagonal {diaonal}");
this.Version = version;
Number = number;
}
}
}
24 changes: 10 additions & 14 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,17 @@ public class Program
{
public static void Main(string[] args)
{
Phone phone1 = new Phone("iPhone", -7);
phone1.Show();
phone1.Diagonal = 7;
phone1.Show();
phone1.Diagonal = -16;
phone1.Show();
// int a = 5;
Phone phone = new Phone();
phone.AcceptCall();
phone.CloseCall();
phone.MakeCall("+1234567");
phone.CloseCall();
Console.WriteLine($"ver={phone.Version} num={phone.Number}");

Phone tablet = new Phone("Android", 6);
tablet.Diagonal = 6;
tablet.Show();
tablet.Diagonal = -10;
tablet.Show();
tablet.Diagonal = 8;
tablet.Show();
Console.WriteLine("Hello World");
Phone phone1 = new Phone(5, "+7000000");
Console.WriteLine($"ver={phone1.Version} num={phone1.Number}");
phone1.AcceptCall();
}
}
}
35 changes: 34 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,37 @@ Finally you may work with migration (from `WebApplication` folder). The followin

```
dotnet ef migrations add InitialMigration
```
```

# Phones Store

Существуют телефоны, которые могут осуществлять голосовой вызов, у них появляются методы - принять вызов, завершить вызов, позвонить.
Существуют сотовые телефоны, которые могут отправить сообщение, принять сообщение, отправить сообщение, а так сбросить вызов.
Существуют смартфоны (различающиеся операционной системой), определяются диагональю экрана, можно установить и запустить приложение
Все телефоны могут быть представлены в магазине.

Phone:
Number {get; set;}
AcceptCall()
CloseCall()
MakeCall(phoneNumber)

CellPhone:
PlayMusic()
SendMessage(number)
GetMessage()
DeclineCall()

Smarphone
Diagonal {get; set;}
OsType {get; set;}
ConnectToInternet()
InstallApp()
StartApp()
UninstallApp()

Iphone14:
lidar()
Redmi14:
Wallet()