public override void AddGrade(double grade)
 {
     try
     {
         if (grade <= 100 && grade >= 0)
         {
             if (grades.Count < maxGradeCount)
             {
                 grades.Add(grade);
                 using (var writer = File.AppendText($"../../../DiskBook/{Name}.txt"))
                 {
                     writer.WriteLine(grade);
                     GradeAdded?.Invoke(this, new EventArgs());
                 }
             }
             else
             {
                 Console.WriteLine($"Reached maximum grade count of: {maxGradeCount}");
             }
         }
         else
         {
             throw new ArgumentException($"Invalid {nameof(grade)}");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #2
0
 public override void AddGrade(double grade)
 {
     using (var writer = File.AppendText($"{TEMPFOLDER}{Name}.txt")) {
         writer.WriteLine(grade);
         GradeAdded?.Invoke(this, new System.EventArgs());
     }
 }
Exemple #3
0
        public override void AddGrade(double grade)
        {
            using var streamWriter = File.AppendText($"{Name}.txt");
            streamWriter.WriteLine(grade);

            GradeAdded?.Invoke(this, new EventArgs());
        }
Exemple #4
0
 public override void AddGrade(double _grade)
 {
     using (var fileWriter = File.AppendText($"{Name}.txt"))
     {
         fileWriter.Write(_grade + "|");
         GradeAdded?.Invoke(this, new EventArgs());
     }
 }
Exemple #5
0
 public override void AddGrade(double grade)
 {
     using (var file = File.AppendText(FilePath))
     {
         file.WriteLine(grade.ToString());
         GradeAdded?.Invoke(this, new EventArgs());
     }
 }
Exemple #6
0
 public override void AddGrade(double grade)
 {
     using (StreamWriter writeBook = File.AppendText($"{Name}Book.txt"))
     {
         writeBook.WriteLine(grade);
         GradeAdded?.Invoke(this, new EventArgs());
     }
 }
Exemple #7
0
 public void AddGrade(double grade)
 {
     if (grade <= 100.0 && grade >= 0.0)
     {
         grades.Add(grade);
         GradeAdded?.Invoke(this, new EventArgs());                 //this is to check if the gradeAdded is not null to know if it was called
     }
     else
     {
         throw new ArgumentException($"Invalid {nameof(grade)}");
     }
 }
Exemple #8
0
 public override void AddGrade(double grade)
 {
     if (grade <= 100 && grade >= 0)
     {
         grades.Add(grade);
         GradeAdded?.Invoke(this, new EventArgs());
     }
     else
     {
         throw new ArgumentException($"Invalid {nameof(grade)}");
     }
 }
Exemple #9
0
 public override void AddGrade(double grade)
 {
     if (grade <= 100 && grade >= 0)
     {
         using var writer = File.AppendText($"{Name}.txt");
         writer.WriteLine(grade);
         GradeAdded?.Invoke(this, new EventArgs());
     }
     else
     {
         throw new ArgumentException($"Invalid {nameof(grade)}");
     }
 }
Exemple #10
0
 public abstract void AddGrade(double grade)
 {
     if (grade <= 100 && grade >= 0)
     {
         grades.Add(grade);
         GradeAdded?.Invoke(this, new EventArgs());
     }
     else
     {
         throw new ArgumentException($"Invalid {nameof(grade)}");
         //Console.WriteLine("Invalid value");
     }
 }
 public override void AddGrade(params double[] grade)
 {
     foreach (double number in grade)
     {
         if (number >= Statistics.MINGRADE && number <= Statistics.MAXGRADE)
         {
             Grades.Add(number);
             GradeAdded?.Invoke(this, new EventArgs( ));
         }
         else
         {
             Console.WriteLine($"Invalid {nameof ( grade )}");
         }
     }
 }
Exemple #12
0
 public override void AddGrade(double grade)
 {
     if (grade <= 100 && grade >= 0)
     {
         grades.Add(grade);
         //if (GradeAdded != null)
         //{
         //    GradeAdded(this, new EventArgs());
         //}
         // The previous code can be simplified in this way in the latest version of C#
         GradeAdded?.Invoke(this, new EventArgs());
     }
     else
     {
         throw new ArgumentException($"Invalid {nameof(grade)}");
     }
 }
Exemple #13
0
        public override void AddGrade(double grade)
        {
            switch (grade)
            {
            case <= 100 and >= 0:
                _grades.Add(grade);
                GradeAdded?.Invoke(this, EventArgs.Empty);
                break;

            case < 0:
                Console.WriteLine("Invalid value! The value must be more than 0!");
                break;

            case > 100:
                Console.WriteLine("Invalid value! The value must be not more than 100!");
                break;
            }
        }
 //Add Grade to Grades List
 public override void AddGrade(Double grade)
 {
     if (grade <= 100 && grade >= 0)
     {
         if (grades.Count < maxGradeCount)
         {
             grades.Add(grade);
             GradeAdded?.Invoke(this, new EventArgs());
         }
         else
         {
             Console.WriteLine($"Reached maximum grade count of: {maxGradeCount}");
         }
     }
     else
     {
         throw new ArgumentException($"Invalid {nameof(grade)}");
     }
 }
        public override void AddGrade(params double[] grade)
        {
            foreach (double number in grade)
            {
                if (number >= Statistics.MINGRADE && number <= Statistics.MAXGRADE)
                {
                    using (var writer = File.AppendText($"{Name}.txt"))
                    {
                        writer.WriteLine(number);
                    }

                    GradeAdded?.Invoke(this, new EventArgs( ));
                }
                else
                {
                    Console.WriteLine($"Invalid {nameof ( grade )}");
                }
            }
        }