Skip to content

Commit edb484d

Browse files
committed
edit
1 parent 5d51e08 commit edb484d

File tree

32 files changed

+683
-521
lines changed

32 files changed

+683
-521
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Globalization;
3+
using System.Linq;
4+
5+
public class CountWorkingDays
6+
{
7+
public static void Main()
8+
{
9+
DateTime[] holidays =
10+
{
11+
new DateTime(4, 1, 1),
12+
new DateTime(4, 3, 3),
13+
new DateTime(4, 5, 1),
14+
new DateTime(4, 5, 6),
15+
new DateTime(4, 5, 24),
16+
new DateTime(4, 9, 6),
17+
new DateTime(4, 9, 22),
18+
new DateTime(4, 11, 1),
19+
new DateTime(4, 12, 24),
20+
new DateTime(4, 12, 25),
21+
new DateTime(4, 12, 26)
22+
};
23+
24+
DateTime startDay = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
25+
DateTime endDay = DateTime.ParseExact(Console.ReadLine(), "dd-MM-yyyy", CultureInfo.InvariantCulture);
26+
int counter = 0;
27+
28+
for (DateTime day = startDay; day <= endDay; day = day.AddDays(1))
29+
{
30+
if (day.DayOfWeek == DayOfWeek.Saturday || day.DayOfWeek == DayOfWeek.Sunday)
31+
{
32+
continue;
33+
}
34+
DateTime current = new DateTime(4, day.Month, day.Day);
35+
36+
if (holidays.Contains(current) == false)
37+
{
38+
counter++;
39+
}
40+
41+
}
42+
43+
Console.WriteLine(counter);
44+
}
45+
}

08.Objects and Classes/Exercises/01.CountWorkingDays/Program.cs

Lines changed: 0 additions & 46 deletions
This file was deleted.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
using System;
2+
3+
public class AdvertisementMessage
4+
{
5+
public static void Main()
6+
{
7+
int countOfAdvertisements = int.Parse(Console.ReadLine());
8+
9+
string[] phrases =
10+
{
11+
"Excellent product.",
12+
"Such a great product.",
13+
"I always use that product.",
14+
"Best product of its category.",
15+
"Exceptional product.",
16+
"I can’t live without this product."
17+
};
18+
string[] events =
19+
{
20+
"Now I feel good.",
21+
"I have succeeded with this product.",
22+
"Makes miracles.I am happy of the results!",
23+
"I cannot believe but now I feel awesome.",
24+
"Try it yourself, I am very satisfied.",
25+
"I feel great!"
26+
};
27+
28+
string[] authors =
29+
{
30+
"Diana",
31+
"Petya",
32+
"Stella",
33+
"Elena",
34+
"Katya",
35+
"Iva",
36+
"Annie",
37+
"Eva"
38+
};
39+
string[] cities =
40+
{
41+
"Burgas",
42+
"Sofia",
43+
"Plovdiv",
44+
"Varna",
45+
"Ruse"
46+
};
47+
Random randomAdv = new Random();
48+
49+
for (int i = 0; i < countOfAdvertisements; i++)
50+
{
51+
string phrase = phrases[randomAdv.Next(0, phrases.Length)];
52+
string eventa = events[randomAdv.Next(0, events.Length)];
53+
string author = authors[randomAdv.Next(0, authors.Length)];
54+
string city = cities[randomAdv.Next(0, cities.Length)];
55+
56+
Console.WriteLine("{0} {1} {2} - {3}", phrase, eventa, author, city);
57+
}
58+
}
59+
}

08.Objects and Classes/Exercises/02.AdvertismentMessage/Program.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Linq;
3+
4+
public class IntersectionOfCircles
5+
{
6+
public static void Main()
7+
{
8+
Circle circle1 = ReadCircle(Console.ReadLine());
9+
Circle circle2 = ReadCircle(Console.ReadLine());
10+
11+
int deltaX = circle1.Center.X - circle2.Center.X;
12+
int deltaY = circle1.Center.Y - circle2.Center.Y;
13+
double distanceBetweenCenters = Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
14+
15+
if (distanceBetweenCenters > circle1.Radius + circle2.Radius)
16+
{
17+
Console.WriteLine("No");
18+
}
19+
else
20+
{
21+
Console.WriteLine("Yes");
22+
}
23+
}
24+
25+
private static Circle ReadCircle(string input)
26+
{
27+
int[] tokens = input.Split(' ').Select(int.Parse).ToArray();
28+
return new Circle { Center = new Point { X = tokens[0], Y = tokens[1] }, Radius = tokens[2] };
29+
}
30+
}
31+
32+
public class Point
33+
{
34+
public int X { get; set; }
35+
public int Y { get; set; }
36+
}
37+
38+
public class Circle
39+
{
40+
public Point Center { get; set; }
41+
public int Radius { get; set; }
42+
}

08.Objects and Classes/Exercises/03.IntersectionOfCircles/Program.cs

Lines changed: 0 additions & 45 deletions
This file was deleted.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
5+
public class AverageGrades
6+
{
7+
public static void Main()
8+
{
9+
int studentsCount = int.Parse(Console.ReadLine());
10+
11+
Student[] students = new Student[studentsCount];
12+
13+
for (int i = 0; i < studentsCount; i++)
14+
{
15+
students[i] = ReadStudent(Console.ReadLine());
16+
}
17+
18+
foreach (Student student in students.Where(x => x.AverageGrade >= 5).OrderBy(x => x.Name).ThenByDescending(x => x.AverageGrade))
19+
{
20+
Console.WriteLine("{0} -> {1:F2}", student.Name, student.AverageGrade);
21+
}
22+
}
23+
24+
private static Student ReadStudent(string input)
25+
{
26+
string[] tokens = input.Split(' ');
27+
List<double> grades = new List<double>();
28+
foreach (string token in tokens.Skip(1))
29+
{
30+
grades.Add(double.Parse(token));
31+
}
32+
33+
return new Student { Name = tokens[0], Grades = grades };
34+
}
35+
}
36+
37+
public class Student
38+
{
39+
public string Name { get; set; }
40+
public List<double> Grades { get; set; }
41+
public double AverageGrade => Grades.Sum() / Grades.Count;
42+
}

08.Objects and Classes/Exercises/04.AverageGrades/Program.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

08.Objects and Classes/Exercises/04.DistanceBetweenPoints/04.DistanceBetweenPoints.csproj

Lines changed: 0 additions & 8 deletions
This file was deleted.

08.Objects and Classes/Exercises/04.DistanceBetweenPoints/Program.cs

Lines changed: 0 additions & 12 deletions
This file was deleted.

0 commit comments

Comments
 (0)