Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _09._02._2019
- {
- class Program
- {
- class Student
- {
- public double ExamPercent { get; private set; } // 0.0−1.0
- public double AttendancePercent { get; private set; } // 0.0−1.0
- public Student(double examPercent, double attendancePercent)
- {
- if (examPercent > 1.0 || attendancePercent > 1.0) throw new ArgumentOutOfRangeException();
- if (examPercent < 0.0 || attendancePercent < 0.0) throw new ArgumentOutOfRangeException();
- ExamPercent = examPercent; AttendancePercent = attendancePercent;
- }
- }
- interface IGrader
- {
- List<bool> CreateNewStudentList(List<Student> student);
- double CalculateAverage(List<Student> student);
- }
- class FeritGrader : IGrader
- {
- public double MinScore { get; private set; }
- public double MinAttendance { get; private set; }
- public FeritGrader(double minScore, double minAttendance)
- {
- //Kontrola granicnih vrijednosti je obavljena, ali izostavljena radi prostora
- MinScore = minScore; MinAttendance = minAttendance;
- }
- public List<bool> CreateNewStudentList(List<Student> student) {
- List<bool> newStudentList = new List<bool>();
- for (int i = 0; i < student.Count(); i++)
- {
- if(student[i].ExamPercent > MinScore && student[i].AttendancePercent > MinAttendance)
- {
- newStudentList.Add(true);
- }
- else
- {
- newStudentList.Add(false);
- }
- }
- return newStudentList;
- }
- public double CalculateAverage(List<Student> student) {
- double sum = 0;
- int counter = 0;
- for (int i = 0; i < student.Count(); i++)
- {
- if (student[i].ExamPercent > MinScore && student[i].AttendancePercent > MinAttendance)
- {
- sum = student[i].ExamPercent;
- counter++;
- }
- }
- return sum / counter;
- }
- }
- void RemoveStudent(List<Student> student)
- {
- for(int i = 0; i < student.Count(); i++){
- if(student[i].AttendancePercent == 0)
- {
- student.RemoveAt(i);
- }
- }
- }
- static void Main(string[] args)
- {
- List<Student> students = RetriveStudentsFromISVU();
- int totalStudents = students.Count();
- RemoveStudent(students);
- int newTotal = students.Count();
- if ((totalStudents - newTotal) > totalStudents / 2){
- Console.WriteLine("Studenata kojih nikad nije bilo je manje od pola.");
- }
- else
- {
- Console.WriteLine("Studenata kojih nikad nije bilo je vise od pola.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement