Skip to content
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
52 changes: 52 additions & 0 deletions Lesson05/Lesson05/Candidate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lesson05
{
internal class Candidate
{
public string FullName { get; set; }
public int Age { get; set; }
public Gender Gender { get; set; }
public Education Education { get; set; }

public Candidate(string fullName, int age, Gender gender, Education education)
{
FullName = fullName;
Age = age;
Gender = gender;
Education = education;
CheckCandidate();
}
public void CheckCandidate()
{
if (Age <= 18)
{
throw new CandidateAdult();
}
if(Gender == Gender.Female)
{
throw new CandidateShouldMale();
}
if(Education != Education.University && Education != Education.Master)
{
throw new ShouldGraduatedUniversity();
}
}
}
enum Gender
{
Male = 1,
Female
}
enum Education
{
Master = 1,
University,
College,
School
}
}
12 changes: 12 additions & 0 deletions Lesson05/Lesson05/CandidateAdult.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lesson05
{
internal class CandidateAdult : CandidateIsNotSuitable
{
}
}
13 changes: 13 additions & 0 deletions Lesson05/Lesson05/CandidateIsNotSuitable.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lesson05
{
internal class CandidateIsNotSuitable : Exception
{

}
}
12 changes: 12 additions & 0 deletions Lesson05/Lesson05/CandidateShouldMale.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lesson05
{
internal class CandidateShouldMale : CandidateIsNotSuitable
{
}
}
46 changes: 45 additions & 1 deletion Lesson05/Lesson05/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,51 @@ internal class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello, World!");
try
{
Console.WriteLine("Ma'lumotaringizni kiriting ");
Console.WriteLine();

Console.Write("Ism familiangiz : ");
string name = Console.ReadLine();

Console.Write("Yoshingiz : ");
int age = int.Parse(Console.ReadLine());

Console.WriteLine("Jinsingiz : 1.Erkak 2.Ayol ");
int gender = int.Parse(Console.ReadLine());

Console.WriteLine("Ma'lumotingiz (1.Magistr \t2.Bakalavr \t3.O'rta maxsus \t4.O'rta)");
int education = int.Parse(Console.ReadLine());

Candidate candidate1 = new Candidate(name,age,(Gender)gender, (Education)education);

}
catch(CandidateAdult)
{
Console.WriteLine("Faqat voyaga yetgan shaxslar qabul qilinadi!");
}
catch (CandidateShouldMale)
{
Console.WriteLine("Uzr faqat erkak ishchilar qabul qilinadi!");
}
catch (ShouldGraduatedUniversity)
{
Console.WriteLine("Universitetni tugating!");
}
catch (Exception)
{
Console.WriteLine("Nimadir xato!");
}
finally
{
Console.WriteLine("================================================");
Console.WriteLine("Xizmatlarimizdan foydalanganingiz uchun rahmat!");
Console.WriteLine();
}
Main(args);
}


}
}
13 changes: 13 additions & 0 deletions Lesson05/Lesson05/ShouldGraduatedUniversity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lesson05
{
internal class ShouldGraduatedUniversity : CandidateIsNotSuitable
{

}
}