Skip to content

Commit

Permalink
Merge pull request ISUCT#1 from ISUCT/jskonst
Browse files Browse the repository at this point in the history
1 classes sample
  • Loading branch information
jskonst authored Sep 3, 2022
2 parents 320c07a + 7d24737 commit 6e6e4d9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
38 changes: 38 additions & 0 deletions CourseApp/Phone.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace CourseApp
{
using System;

public class Phone
{
private float diaonal;

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

public string Name { get; set; }

public float Diagonal
{
get
{
return diaonal;
}

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

public void Show()
{
Console.WriteLine($"{Name} with diagonal {diaonal}");
}
}
}
14 changes: 14 additions & 0 deletions CourseApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ 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();

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");
}
}
Expand Down

0 comments on commit 6e6e4d9

Please sign in to comment.