Finished Defining an Abstract Class

oop
Jason Zhu 2021-02-22 23:19:37 +00:00
parent fe71127f3a
commit 55ce261ed8
1 changed files with 18 additions and 4 deletions

View File

@ -19,7 +19,15 @@ namespace GradeBook
}
}
public abstract class Book : NamedObject
public interface IBook
{
void AddGrade(double grade);
Statistics GetStatistics();
string Name { get; }
event GradeAddedDelegate GradeAdded;
}
public abstract class Book : NamedObject, IBook
{
// Abstract class used to act as entrypoint for other class, so output
// can change based on given input. At this level, we cannot provide implementation
@ -30,8 +38,14 @@ namespace GradeBook
}
public abstract void AddGrade(double grade);
public virtual event GradeAddedDelegate GradeAdded;
public virtual Statistics GetStatistics()
{
throw new NotImplementedException();
}
}
public class InMemoryBook : Book
public class InMemoryBook : Book, IBook
{
private List<double> grades;
@ -81,9 +95,9 @@ namespace GradeBook
}
}
public event GradeAddedDelegate GradeAdded;
public override event GradeAddedDelegate GradeAdded;
public Statistics GetStatistics()
public override Statistics GetStatistics()
{
var result = new Statistics();
result.Average = 0.0;