Created
November 19, 2015 19:36
-
-
Save Jore2/af6ddb155779d6962d39 to your computer and use it in GitHub Desktop.
04.SoftUni
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class CurrentStudent:Student | |
{ | |
private string course; | |
public string Course | |
{ | |
get | |
{ | |
return this.course; | |
} | |
set | |
{ | |
this.course = value; | |
} | |
} | |
public CurrentStudent(string studentNumber,double averageGrade,string course):base(studentNumber,averageGrade) | |
{ | |
this.Course = course; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class DropoutStudent:Student | |
{ | |
private string dropOutReason; | |
public string DropOutReason | |
{ | |
get | |
{ | |
return this.dropOutReason; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentNullException(); | |
} | |
else | |
{ | |
this.dropOutReason = value; | |
} | |
} | |
} | |
public DropoutStudent(string studentNumber,double averageGrade,string dropOutReason):base(studentNumber,averageGrade) | |
{ | |
this.DropOutReason = dropOutReason; | |
} | |
public static void Reapply(DropoutStudent dropOutStudent) | |
{ | |
Console.WriteLine("Student Full Name: {0}.\nStudent Age: {1}.\nStudent Number: {2}.\nStudent Average Grade: {3}.\nReason for dropOut: {4}.",dropOutStudent.FirstName +' '+ dropOutStudent.LastName, | |
dropOutStudent.Age,dropOutStudent.StudentNumber,dropOutStudent.AverageGrade,dropOutStudent.DropOutReason); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class GraduatedStudent:Student | |
{ | |
public GraduatedStudent(string studentNUmber,double averageGrade):base(studentNUmber,averageGrade) | |
{ | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class JuniorTrainer:Trainer | |
{ | |
public JuniorTrainer(string firstName,string secondName,int age):base(firstName,secondName,age) | |
{ | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class OnlineStudent:CurrentStudent | |
{ | |
public OnlineStudent(string studentNumber,double averageGrade,string course):base(studentNumber,averageGrade,course) | |
{ | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class OnSiteStudent:CurrentStudent | |
{ | |
public int NumberOfVisits { get; set; } | |
public OnSiteStudent(string studentNumber,double averageGrade,string course,int visits):base(studentNumber,averageGrade,course) | |
{ | |
this.NumberOfVisits = visits; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
public class Person | |
{ | |
private string firstName; | |
private string lastName; | |
private int age; | |
public string FirstName | |
{ | |
get | |
{ | |
return this.firstName; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentNullException(); | |
} | |
this.firstName = value; | |
} | |
} | |
public string LastName | |
{ | |
get | |
{ | |
return this.lastName; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentNullException(); | |
} | |
this.lastName = value; | |
} | |
} | |
public int Age | |
{ | |
get | |
{ | |
return this.age; | |
} | |
set | |
{ | |
if (value<18) | |
{ | |
throw new ArgumentException("Student must be more than 18 years."); | |
} | |
this.age = value; | |
} | |
} | |
public Person(string firstName,string secondName,int age) | |
{ | |
this.FirstName = firstName; | |
this.LastName = secondName; | |
this.Age = age; | |
} | |
public Person():this("Georgi","Nikolov",18) | |
{ | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class SeniorTrainer:Trainer | |
{ | |
public SeniorTrainer(string firstName, string secondName, int age):base(firstName,secondName,age) | |
{ | |
} | |
public void DeleteCourse(string course) | |
{ | |
if (courses.Contains(course)) | |
{ | |
Console.WriteLine("The {0} course has been deleted.", course); | |
courses.Remove(course); | |
} | |
else | |
{ | |
throw new ArgumentException("Course with that name doest not exist."); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class Student:Person | |
{ | |
private string studentNumber; | |
private double averageGrade; | |
public string StudentNumber | |
{ | |
get | |
{ | |
return this.studentNumber; | |
} | |
set | |
{ | |
if (string.IsNullOrEmpty(value)) | |
{ | |
throw new ArgumentNullException(); | |
} | |
else | |
{ | |
this.studentNumber = value; | |
} | |
} | |
} | |
public double AverageGrade | |
{ | |
get | |
{ | |
return this.averageGrade; | |
} | |
set | |
{ | |
if (value < 2 || value > 6) | |
{ | |
throw new ArgumentException("Grade must be in range 2-6"); | |
} | |
else | |
{ | |
this.averageGrade = value; | |
} | |
} | |
} | |
public Student(string firstName, string secondName, int age):base(firstName,secondName,age) | |
{ | |
} | |
public Student(string studentNumber,double averageGrade) | |
{ | |
this.StudentNumber = studentNumber; | |
this.AverageGrade = averageGrade; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
class SulsTest | |
{ | |
static void Main(string[] args) | |
{ | |
//Student s = new Student("12314", 4.5); | |
//GraduatedStudent d = new GraduatedStudent("123541", 3.5); | |
//DropoutStudent a = new DropoutStudent("5125544", 2.4, "Low Results"); | |
//DropoutStudent.Reapply(a); | |
List<object> list = new List<object>(); | |
list.Add(new Student("1231254", 4.5)); | |
list.Add(new Trainer("Gosho", "Toshev", 19)); | |
list.Add(new CurrentStudent("5126677", 6.00, "Math")); | |
list.Add(new CurrentStudent("5121377", 5.50, "Math")); | |
list.Add(new CurrentStudent("3126647", 5.50, "Math")); | |
list.Add(new CurrentStudent("1021333", 6.00, "Math")); | |
list.Add(new CurrentStudent("2561346", 4.00, "Math")); | |
list.Add(new CurrentStudent("3031522", 5.50, "Math")); | |
var result = list.Where(e => e is CurrentStudent).Cast<CurrentStudent>().ToList().OrderBy(d => d.AverageGrade); | |
foreach (var item in result) | |
{ | |
Console.WriteLine("Student Name: {0}",item.FirstName + ' '+item.LastName); | |
Console.WriteLine("Age: {0}",item.Age); | |
Console.WriteLine("Student Number: {0}",item.StudentNumber); | |
Console.WriteLine("Average Grade: {0}",item.AverageGrade); | |
Console.WriteLine("Course that student visits: {0}",item.Course); | |
Console.WriteLine(); | |
} | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace _04.SoftUni | |
{ | |
public class Trainer:Person | |
{ | |
protected List<string> courses { get; set; } | |
public Trainer(string firstName,string secondName,int age):base(firstName,secondName,age) | |
{ | |
courses = new List<string>(); | |
} | |
public void CreateCourse(string course) | |
{ | |
courses.Add(course); | |
Console.WriteLine("The {0} course has been created.",course); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment