From f7ef36beabbefa92e973c1f3c031ab71d5e88c2c Mon Sep 17 00:00:00 2001 From: Jason Zhu Date: Mon, 22 Feb 2021 11:53:59 +0000 Subject: [PATCH] Finished Deriving from a Base Class --- gradebook/src/GradeBook/Book.cs | 22 +++++++++++++++------- gradebook/src/GradeBook/Program.cs | 8 -------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gradebook/src/GradeBook/Book.cs b/gradebook/src/GradeBook/Book.cs index d45358e..e2f704b 100644 --- a/gradebook/src/GradeBook/Book.cs +++ b/gradebook/src/GradeBook/Book.cs @@ -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 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(); diff --git a/gradebook/src/GradeBook/Program.cs b/gradebook/src/GradeBook/Program.cs index 54de553..2134bdd 100644 --- a/gradebook/src/GradeBook/Program.cs +++ b/gradebook/src/GradeBook/Program.cs @@ -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;