+ Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sed
+ blanditiis, consequuntur, soluta labore incidunt repudiandae?
+ In dolorum rem voluptas soluta dolore, quae autem, natus hic
+ numquam obcaecati aliquam, molestiae fugit!
+
+
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit.
+ Quibusdam at maxime sunt, magni officia consequuntur,
+ voluptate cumque sint voluptatibus facilis rerum, voluptas?
+ Labore, ab consequuntur optio ipsum alias dolores, eius!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CourseApp.Tests/AgeTest.cs b/CourseApp.Tests/AgeTest.cs
new file mode 100644
index 0000000..2cbfd5a
--- /dev/null
+++ b/CourseApp.Tests/AgeTest.cs
@@ -0,0 +1,45 @@
+using System;
+using Xunit;
+
+namespace CourseApp.Tests
+{
+ public class AgeTest
+ {
+ [Fact]
+ public void TestDate()
+ {
+ double a = DateTime.Now.Ticks - new DateTime(1998, 08, 04).Ticks;
+ double b = AgeClass.DateCompare(new DateTime(1998, 08, 04), DateTime.Now).Ticks;
+ if (b - a > 0.000000001)
+ {
+ Assert.True(true);
+ }
+ }
+
+ [Fact]
+ public void TestTodayBirthday()
+ {
+ try
+ {
+ Assert.Equal(0, DateTime.Compare(DateTime.Now, AgeClass.DateCompare(DateTime.Now, DateTime.Now)));
+ }
+ catch (Exception)
+ {
+ Console.WriteLine("Birthday == Today");
+ }
+ }
+
+ [Fact]
+ public void BirthdayAboveToday()
+ {
+ try
+ {
+ Assert.Equal(0, DateTime.Compare(DateTime.Now, AgeClass.DateCompare(DateTime.Now, new DateTime(2048, 8, 16))));
+ }
+ catch (Exception)
+ {
+ Console.WriteLine("Birthday > Today");
+ }
+ }
+ }
+}
diff --git a/CourseApp.Tests/PersonTest.cs b/CourseApp.Tests/PersonTest.cs
index bc89213..4ad4ec2 100644
--- a/CourseApp.Tests/PersonTest.cs
+++ b/CourseApp.Tests/PersonTest.cs
@@ -6,33 +6,54 @@ namespace CourseApp.Tests
public class PersonTest
{
[Fact]
- public void TestConstructor()
+ public void TestConstructorStudent()
{
- var item = new Person();
+ var item = new Student();
Assert.Equal(18, item.Age);
Assert.Equal("Name", item.Name);
Assert.Equal("LastName", item.LastName);
+ Assert.True(item.IsMale);
+ Assert.True(item.Starvation);
}
[Fact]
- public void TestSetAge()
+ public void TestConstructorChildren()
{
- var item = new Person();
- item.Age = 30;
- Assert.Equal(30, item.Age);
+ var item = new Children();
+ Assert.Equal(1, item.Age);
+ Assert.Equal("Name", item.Name);
+ Assert.Equal("LastName", item.LastName);
+ Assert.True(item.IsMale);
+ Assert.False(item.Happy);
+ }
+
+ [Fact]
+ public void TestSetAgeChildren()
+ {
+ var item = new Children();
+ item.Age = 9;
+ Assert.Equal(9, item.Age);
+ }
+
+ [Fact]
+ public void TestSetAgeStudent()
+ {
+ var item = new Student();
+ item.Age = 20;
+ Assert.Equal(20, item.Age);
}
[Fact]
- public void TestIncorrectSetAge()
+ public void TestIncorrectSetAgeChildren()
{
try
{
- var item = new Person();
+ var item = new Children();
item.Age = -1000;
}
catch (System.Exception)
{
- Console.WriteLine("Age should be more 0 and less than 100");
+ Console.WriteLine("Age should be more 0 and less than 12");
Assert.True(true);
}
}
@@ -40,7 +61,7 @@ public void TestIncorrectSetAge()
[Fact]
public void TestCorrectIncorrectSetAge()
{
- var item = new Person();
+ var item = new Student();
item.Age = 27;
try
{
@@ -54,25 +75,5 @@ public void TestCorrectIncorrectSetAge()
Assert.Equal(27, item.Age);
}
-
- [Fact]
- public void TestIncorrectSetString()
- {
- var item = new Person();
- item.Name = string.Empty;
- item.LastName = string.Empty;
- Assert.Equal(string.Empty, item.Name);
- Assert.Equal(string.Empty, item.LastName);
- }
-
- [Fact]
- public void TestCorrectSetString()
- {
- var item = new Person();
- item.Name = "VikiVik";
- item.LastName = "Moro";
- Assert.Equal("VikiVik", item.Name);
- Assert.Equal("Moro", item.LastName);
- }
}
}
diff --git a/CourseApp/AgeClass.cs b/CourseApp/AgeClass.cs
new file mode 100644
index 0000000..5697515
--- /dev/null
+++ b/CourseApp/AgeClass.cs
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+
+namespace CourseApp
+{
+ public class AgeClass
+ {
+ public static string Age()
+ {
+ Console.WriteLine("Введите год своего рождения:");
+ int years = Convert.ToInt32(Console.ReadLine());
+ Console.WriteLine("Введите месяц своего рождения:");
+ int months = Convert.ToInt32(Console.ReadLine());
+ Console.WriteLine("Введите день своего рождения:");
+ int days = Convert.ToInt32(Console.ReadLine());
+ DateTime result = DateCompare(new DateTime(years, months, days), DateTime.Now);
+ return $"Вам {result.Year - 1} лет, {result.Month - 1} месяцев и {result.Day - 1} дня";
+ }
+
+ public static string Age(int days, int months, int years)
+ {
+ DateTime result = DateCompare(new DateTime(years, months, days), DateTime.Now);
+ return $"Вам {result.Year - 1} лет, {result.Month - 1} месяцев и {result.Day - 1} дня";
+ }
+
+ public static DateTime DateCompare(DateTime date1, DateTime date2)
+ {
+ if (date1.Ticks < date2.Ticks)
+ {
+ DateTime res = new DateTime(date2.Ticks - date1.Ticks);
+ return res;
+ }
+
+ throw new Exception();
+ }
+
+ public static string Age(DateTime date)
+ {
+ return $"Вам {DateCompare(date, DateTime.Now).Year - 1} лет, {DateCompare(date, DateTime.Now).Month - 1} месяцев и {DateCompare(date, DateTime.Now).Day - 1} дня";
+ }
+ }
+}
diff --git a/CourseApp/Children.cs b/CourseApp/Children.cs
new file mode 100644
index 0000000..077999d
--- /dev/null
+++ b/CourseApp/Children.cs
@@ -0,0 +1,66 @@
+using System;
+
+namespace CourseApp
+{
+ public class Children : Person
+ {
+ public Children()
+ : this("Name")
+ {
+ }
+
+ public Children(string name)
+ : this(name, "LastName")
+ {
+ }
+
+ public Children(string name, string lastname)
+ : this(name, lastname, 1)
+ {
+ }
+
+ public Children(string name, string lastname, int age)
+ : this(name, lastname, age, true)
+ {
+ }
+
+ public Children(string name, string lastname, int age, bool isMale)
+ : this(name, lastname, age, isMale, false)
+ {
+ }
+
+ public Children(string name, string lastname, int age, bool isMale, bool happy)
+ : base(name, lastname, age, isMale)
+ {
+ this.Happy = happy;
+ }
+
+ public bool Happy { get; set; }
+
+ public override int Age
+ {
+ set
+ {
+ if (value >= 0 && value < 12)
+ {
+ base.Age = value;
+ }
+ else
+ {
+ throw new System.Exception("Age should be more 0 and less than 12");
+ }
+ }
+ }
+
+ public override string ToString()
+ {
+ string s = $"Hi. I am {Name} {LastName}. I am {Age} years old. I am a {(IsMale ? "male" : "female")} and {(Happy ? "unhappy" : "happy")}";
+ return s;
+ }
+
+ public override string Replica()
+ {
+ return "I want to go to school";
+ }
+ }
+}
\ No newline at end of file
diff --git a/CourseApp/Person.cs b/CourseApp/Person.cs
index e069e53..c0f3887 100644
--- a/CourseApp/Person.cs
+++ b/CourseApp/Person.cs
@@ -2,7 +2,7 @@
namespace CourseApp
{
- public class Person
+ public abstract class Person
{
private int age;
@@ -22,13 +22,19 @@ public Person(string name, string lastname)
}
public Person(string name, string lastname, int age)
+ : this(name, lastname, age, true)
+ {
+ }
+
+ public Person(string name, string lastname, int age, bool isMale)
{
this.Name = name;
this.LastName = lastname;
this.age = age;
+ this.IsMale = isMale;
}
- public int Age
+ public virtual int Age
{
get
{
@@ -52,10 +58,14 @@ public int Age
public string LastName { get; set; }
+ public bool IsMale { get; set; }
+
public override string ToString()
{
- string s = $"Hi. I am {Name} {LastName}. I am {Age} years old.";
+ string s = $"Hi. I am {Name} {LastName}. I am {Age} years old. I am a {(IsMale ? "male" : "female")}";
return s;
}
+
+ public abstract string Replica();
}
}
\ No newline at end of file
diff --git a/CourseApp/Program.cs b/CourseApp/Program.cs
index ac6d37a..f32636c 100644
--- a/CourseApp/Program.cs
+++ b/CourseApp/Program.cs
@@ -59,14 +59,20 @@ public static void Main(string[] args)
Console.WriteLine($"y = {item}");
}
- Person[] people = new Person[2];
- people[0] = new Person("Sasha", "Smirnov", 25);
- people[1] = new Person("Polina", "Suvorova", 22);
- foreach (var item in people)
+ Console.WriteLine();
+
+ Person[] masss = new Person[2];
+ masss[0] = new Student("Artem", "Scherbinin", 18, true, true);
+ masss[1] = new Children("Alina", "Kotova", 7, false, true);
+ foreach (var item in masss)
{
- Console.WriteLine(item);
+ Console.WriteLine(item.ToString());
+ Console.WriteLine(item.Replica());
+ Console.WriteLine();
}
+ Console.WriteLine(AgeClass.Age());
+ Console.WriteLine();
Console.ReadLine();
}
}
diff --git a/CourseApp/Student.cs b/CourseApp/Student.cs
new file mode 100644
index 0000000..e5e2599
--- /dev/null
+++ b/CourseApp/Student.cs
@@ -0,0 +1,51 @@
+using System;
+
+namespace CourseApp
+{
+ public class Student : Person
+ {
+ public Student()
+ : this("Name")
+ {
+ }
+
+ public Student(string name)
+ : this(name, "LastName")
+ {
+ }
+
+ public Student(string name, string lastname)
+ : this(name, lastname, 18)
+ {
+ }
+
+ public Student(string name, string lastname, int age)
+ : this(name, lastname, age, true)
+ {
+ }
+
+ public Student(string name, string lastname, int age, bool isMale)
+ : this(name, lastname, age, isMale, true)
+ {
+ }
+
+ public Student(string name, string lastname, int age, bool isMale, bool starvation)
+ : base(name, lastname, age, isMale)
+ {
+ this.Starvation = starvation;
+ }
+
+ public bool Starvation { get; set; }
+
+ public override string ToString()
+ {
+ string s = $"Hi. I am {Name} {LastName}. I am {Age} years old. I am a {(IsMale ? "male" : "female")} and {(Starvation ? "hungry" : "full")}";
+ return s;
+ }
+
+ public override string Replica()
+ {
+ return "I want to go to kindergarten";
+ }
+ }
+}
\ No newline at end of file
diff --git a/Info.html b/Info.html
new file mode 100644
index 0000000..dbeef10
--- /dev/null
+++ b/Info.html
@@ -0,0 +1,194 @@
+
+
+
+
+
+
+
+
+
+
+
+ Moro WebSite
+
+
+
+
+
+
+
+ DressCodeBoy
+
+
+