Finished Deriving from a Base Class

oop
Jason Zhu 2021-02-22 11:53:59 +00:00
parent 2b07530bb3
commit f7ef36beab
2 changed files with 15 additions and 15 deletions

View File

@ -5,20 +5,28 @@ namespace GradeBook
{
public delegate void GradeAddedDelegate(object sender, EventArgs args);
public class Book
public class NamedObject
{
public NamedObject(string name)
{
Name = name;
}
public string Name
{
get;
set;
}
}
public class Book : NamedObject
{
private List<double> grades;
readonly string category;
private string name;
public string Name
{
get;
set;
}
public Book(string name)
public Book(string name) : base(name)
{
Name = name;
grades = new List<double>();

View File

@ -8,16 +8,8 @@ namespace GradeBook
static void Main(string[] args)
{
// var book = new Book("Scott's Grade Book");
// book.AddGrade(89.1);
// book.AddGrade(90.5);
// book.AddGrade(87.2);
var book = new Book("Jason's Grade Book");
book.GradeAdded += OnGradeAdded;
book.GradeAdded += OnGradeAdded;
book.GradeAdded -= OnGradeAdded;
book.GradeAdded -= OnGradeAdded;
string input;