public void LetterGradeTest() { var gradeBook1 = new GradeBook(); gradeBook1.AddGrade(90); gradeBook1.AddGrade(100); var stats1 = gradeBook1.ComputeStatistics(); Assert.AreEqual("A", stats1.LetterGrade); var gradeBook2 = new GradeBook(); gradeBook2.AddGrade(80); gradeBook2.AddGrade(87); var stats2 = gradeBook2.ComputeStatistics(); Assert.AreEqual("B", stats2.LetterGrade); var gradeBook3 = new GradeBook(); gradeBook3.AddGrade(77); gradeBook3.AddGrade(79); var stats3 = gradeBook3.ComputeStatistics(); Assert.AreEqual("C", stats3.LetterGrade); var gradeBook4 = new GradeBook(); gradeBook4.AddGrade(67); gradeBook4.AddGrade(61); var stats4 = gradeBook4.ComputeStatistics(); Assert.AreEqual("D", stats4.LetterGrade); var gradeBook5 = new GradeBook(); gradeBook5.AddGrade(58); gradeBook5.AddGrade(12); var stats5 = gradeBook5.ComputeStatistics(); Assert.AreEqual("F", stats5.LetterGrade); }
static void Main(string[] args) { Arrays(); //Immutable(); GradeBook book = new GradeBook("Scott's book"); book.AddGrade(91f); book.AddGrade(89.1f); book.AddGrade(75f); GradeStatistics stats = book.ComputeStatistics(); book.NameChanged = new NamedChangedDelegate(OnNameChanged); book.NameChanged += OnNameChanged; book.NameChanged += OnNameChanged2; book.Name = "Allen's book"; WriteNames(book.Name); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.LowestGrade); Console.WriteLine(stats.HighestGrade); Console.ReadLine(); }
private static void exampleDelegate() { Console.WriteLine("Starting Delegate example"); GradeBook book = new GradeBook(); book.AddGrade(92); book.AddGrade(34); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); //using delegate - this will later be triggered any time the name changes later. // book.NameChanged = new NameChangedDelegate(OnNameChanged); //alternate method : multi cast delegate //multiple subscribers to execute when the event occurs book.NameChanged += OnNameChanged; book.NameChanged += OnNameChanged2; //can unsubscribe from this event // book.NameChanged -= OnNameChanged2; book.Name = "changed name"; WriteNames(book.Name); Console.WriteLine("Avg:" + stats.AverageGrade); Console.WriteLine("Lowest" + stats.LowestGrade); Console.WriteLine("Highest" + stats.HighestGrade); }
public void ComputeLowestGrade() { GradeBook book = new GradeBook(); book.AddGrade(90.5f); book.AddGrade(82); GradeStatistics result = book.ComputeStatistics(); Assert.AreEqual(82, result.LowestGrade); }
public void ComputeAverageGrade() { GradeBook book = new GradeBook(); book.AddGrade(90.5f); book.AddGrade(82); GradeStatistics result = book.ComputeStatistics(); Assert.AreEqual(86.25, result.AverageGrade); }
public void LowestGradeTest() { var gradeBook = new GradeBook(); gradeBook.AddGrade(90); gradeBook.AddGrade(10); var stats = gradeBook.ComputeStatistics(); Assert.AreEqual(10, stats.LowestGrade); }
public void CalculateHighestGrade() { GradeBook book = new GradeBook(); book.AddGrade(90f); book.AddGrade(50f); GradeStats stats = book.ComputeStats(); Assert.AreEqual(90f, stats.HighestGrade); }
public void IsGradeValid() { GradeBook book = new GradeBook(); book.AddGrade(90f); book.AddGrade(70f); Assert.AreEqual(2, book._grades.Count); }
public void ComputesLowestGrade() { Grades.GradeBook book = new Grades.GradeBook(); book.AddGrade(10); book.AddGrade(90); Grades.GradeStatistics result = book.ComputeStatistics(); Assert.Equal(10, result.LowestGrade); }
public void ComputesHighestGrade() { GradeBook book = new GradeBook(); book.AddGrade(10); book.AddGrade(90); GradeStatistics result = book.ComputeStatistics(); Assert.AreEqual(90, result.HighestGrade); }
public void ComputesAverageGrade() { Grades.GradeBook book = new Grades.GradeBook(); book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); Grades.GradeStatistics result = book.ComputeStatistics(); Assert.Equal(85.17, result.AverageGrade, 2); }
public void AverageGradeTest() { var gradeBook = new GradeBook(); gradeBook.AddGrade(90); gradeBook.AddGrade(10); gradeBook.AddGrade(0); var stats = gradeBook.ComputeStatistics(); Assert.AreEqual(33.33f, stats.Average, 0.01); }
public void ComputesAverageGrade() { GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics result = book.ComputeStatistics(); Assert.AreEqual(85.16, result.AverageGrade, 0.01); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HighestGrade); Console.WriteLine(stats.LowestGrade); }
public void CalculateHighestGradeCorrectly() { GradeBook book = new GradeBook(); book.AddGrade(90f); book.AddGrade(80f); GradeStatistics stats = book.ComputeStatistics(); Assert.AreEqual(90f, stats.HighesetGrade); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(98.6f); GradeStatistocs stats = book.ComputeStatistocs(); GradeBook book2 = book; book2.AddGrade(75); }
public void LowestGradeTest() { GradeBook book = new GradeBook(); book.AddGrade(90); book.AddGrade(50); GradeStatistics stats = book.ComputeStatistics(); Assert.AreEqual(50, stats.LowestGrade); }
public void AverageGradeTest() { GradeBook book = new GradeBook(); book.AddGrade(90f); book.AddGrade(50f); GradeStatistics stats = book.ComputeStatistics(); Assert.AreEqual(70, stats.AverageGrade); }
public void HighestGradeTest() { GradeBook book = new GradeBook(); book.AddGrade(90f); book.AddGrade(50f); GradeStatistics stats = book.ComputeStatistics(); Assert.AreEqual(90f, stats.HighestGrade); }
public void CalculatesHighestGrade() { bool value = true; GradeBook book = new GradeBook(); book.AddGrade(90f); book.AddGrade(33f); GradeStatistics stats = book.ComputeStatistics(); Assert.AreEqual(90f, stats.HighestGrade); }
public void CalculatesHighestGrade() { GradeBook book = new GradeBook(); book.AddGrade(90f); book.AddGrade(2f); book.AddGrade(100f); GradeStatistics stats = book.ComputeStatistics(); Assert.AreEqual(100f, stats.HighestGrade); //Assert.IsTrue(value); }
static void Main(string[] args) { SpeechSynthesizer synth = new SpeechSynthesizer(); synth.Speak("Hello! this is the real life?"); GradeBook book = new GradeBook(); //invoke the constructor to make a new Gradebook object book.AddGrade(91); book.AddGrade(89.5f); // apply an 'f' to show that it's a floating point number book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HighestGrade); Console.WriteLine(stats.LowestGrade); }
public void CalculateHighestGrade() { GradeBook book = new GradeBook(); book.AddGrade(89); book.AddGrade(70); book.AddGrade(42); GradeStatistics stats = book.ComputeStatistics(); float highestGrade = stats.HighestGrade; Assert.AreEqual(highestGrade, 89f); }
static void Main(string[] args) { GradeBook book = new GradeBook("Delan's Book"); book.AddGrade(91); book.AddGrade(89.1f); book.AddGrade(90f); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine("Average: " + stats.AverageGrade); Console.WriteLine("Highest: " + stats.HighestGrade); Console.WriteLine("Lowest: " + stats.LowestGrade); Console.WriteLine("{0}, {1}", stats.LetterGrade, stats.Description); }
private static void ClassesAndTypes() { GradeBook book = new GradeBook(); //or default value GradeBook book = new GradeBook(string name ="Default Book"); book.AddGrade(92); book.AddGrade(34); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); WriteNames(book.Name); Console.WriteLine("Avg:" + stats.AverageGrade); Console.WriteLine("Lowest" + stats.LowestGrade); Console.WriteLine("Highest" + stats.HighestGrade); }
public void ComputesLetterGrade() { GradeBook book = new GradeBook(); book.AddGrade(88); GradeStatistics result = book.ComputeStatistics(); Assert.AreEqual("B", result.LetterGrade); }
private static void FillGradeBookWithRandomGrades(GradeBook GradeBook) { Random Random = new Random(); GradeBook.Name = "John Doe"; for (int i = 0; i < 6; i++) { GradeBook.AddGrade(Random.Next(75, 100)); } }
static void Main(string[] args) { SpeechSynthesizer synth = new SpeechSynthesizer(); synth.Speak("Hello, World!"); Arrays(); Immutable(); PassByValueAndRef(); GradeBook book = new GradeBook(); book.AddGrade(91f); book.AddGrade(89.5f); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine("Average grade: {0}", stats.AverageGrade); Console.WriteLine("Highest grade: {0}", stats.HighestGrade); Console.WriteLine("Lowest grade: {0}", stats.LowestGrade); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.NameChanged += new NameChangedDelegate(OnNameChanged); book.Name = "Randy's Grade Book"; book.Name = "Grade Book"; book.Name = null; book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); WriteResult("Lowest", stats.LowestGrade); }
static void Main(string[] args) { GradeBook GradeBook = new GradeBook(); bool Done = false; int MaxNumberOfAttempts = 5; int NumberOfAttempts = 0; while (!Done) { Console.WriteLine("Please enter name of file containing student grades."); try { using (FileStream stream = File.Open(Console.ReadLine(), FileMode.Open)) using (StreamReader reader = new StreamReader(stream)) { string line = reader.ReadLine(); while (line != null) { float grade = float.Parse(line); GradeBook.AddGrade(grade); line = reader.ReadLine(); } Console.WriteLine("Student's grades:"); foreach (float grade in GradeBook.GetGrades()) { Console.WriteLine(grade); } Console.WriteLine(GradeBook.Name); Console.WriteLine("Average grade:" + GradeBook.LetterGrade + " (" + GradeBook.AverageGrade() +")"); Console.WriteLine("Highest grade:" + GradeBook.HighestGrade()); Console.WriteLine("Lowest grade:" + GradeBook.LowestGrade()); Done = true; } } catch (DirectoryNotFoundException ex) { Console.WriteLine("Invalid entry, please try again."); } catch (ArgumentException ex) { Console.WriteLine("Invalid entry, please try again."); } catch (FileNotFoundException ex) { Console.WriteLine("Could not find the file grades.txt"); } catch (UnauthorizedAccessException ex) { Console.WriteLine("You do not have access to grades.txt"); } NumberOfAttempts++; if (NumberOfAttempts > MaxNumberOfAttempts) { Console.WriteLine("Max number of attempts exceeded, exiting."); Done = true; } } Console.Read(); }
static void Main(string[] args) { // After adding the Reference "System.Speech" and adding a "using System.Speech.Synthesis;" statement to the top of this document, // we are able to create an instance of the SpeechSynthesizer class and use it's Speak() method to have the synthesizer speak a string input // SpeechSynthesizer synth = new SpeechSynthesizer(); // synth.Speak("Hello, this is the grade book program."); // Similar to Java, we must create a new GradeBook Object using the 'new' operator aka by using a Constructor GradeBook book = new GradeBook(); book.AddGrade(91); // We can only call the methods of a class AFTER making a new object of that class book.AddGrade(89.5f); // Decimal numbers are double by default in C# // We must explicitly convert double to float by adding an "f" after all decimal numbers book.AddGrade(75); // Create a separate class for "Statistics" and separate it from the GradeBook (which is only for storing the grades) GradeStatistics stats = book.ComputeStatistics(); WriteResult("Average Grade", stats.avgGrade); WriteResult("Highest Grade", (int)stats.highestGrade); WriteResult("Lowest Grade", stats.lowestGrade); }
static void Main(string[] args) { GradeBook book = new GradeBook(); GetBookName(book); book.AddGrade(75); book.AddGrade(91); book.AddGrade(99); book.AddGrade(12); book.AddGrade(89.5f); SaveGrades(book); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", stats.AverageGrade); String m = stats.AverageGrade.ToString(); WriteResult("Lowest", m); WriteResult(stats.Description, stats.LetterGrade); }
static void Main(string[] args) { GradeBook book = new GradeBook("Éder's book"); book.AddGrade(77); book.AddGrade(54.25f); book.AddGrade(41f); GradeStatistics stats = book.ComputeStatistics(); book.NameChanged += OnNameChanged; book.NameChanged += OnNameChanged; book.NameChanged += OnNameChanged2; book.NameChanged -= OnNameChanged; book.Name = "Henrique's book"; WriteNames(book.Name); //Console.WriteLine(stats.AverageGrade); //Console.WriteLine(stats.LowestGrade); //Console.WriteLine(stats.HighestGrade); }
static void Main(string[] args) { GradeBook book = new GradeBook("Borys's Book"); try { using (FileStream stream = File.Open("grade.txt", FileMode.Open)) using (StreamReader reader = new StreamReader(stream)) { string line = reader.ReadLine(); while (line != null) { float grade = float.Parse(line); book.AddGrade(grade); line = reader.ReadLine(); } } } catch (FileNotFoundException ex) { Console.WriteLine("Could not locate the file grades.txt"); return; } catch (UnauthorizedAccessException ex) { Console.WriteLine("No access"); return; } book.WriteGrades(Console.Out); // dajcie zapętlenie do poprawnego wpisania nazwy dziennika. String.IsNullOrEmpty try { Console.WriteLine("Please enter a name for the book"); book.Name = Console.ReadLine(); } catch (ArgumentException ex) { Console.WriteLine("Invalid Name"); } GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HighestGrade); Console.WriteLine(stats.LowestGrade); Console.WriteLine("{0} - {1}", stats.LetterGrade, stats.Description); Console.ReadLine(); }
static void Main(string[] args) { SpeechSynthesizer synth = new SpeechSynthesizer(); synth.SelectVoiceByHints(VoiceGender.Female); // make a new gradebook GradeBook book = new GradeBook(); // register an event delegate book.NameChanged += OnNameChanged; // trigger the event book.Name = "The Grade Book"; book.NameChanged += OnNameChanged; synth.Speak("Welcome to: " + book.Name); //book.NameChanged = null; //book.NameChanged = new NameChangedDelegate(OnNameChanged2); // trigger it again book.Name = "Chuck's Grade Book"; synth.Speak("Welcome to: " + book.Name); book.AddGrade(91); // int can convert to float safely book.AddGrade(89.5f); // double can't convert to float safely book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); WriteResult("Lowest", stats.LowestGrade); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.nameChanged += OnNameChanged; book.Name = "Eric's Gradebook"; book.AddGrade(95); book.AddGrade(89.5f); book.AddGrade(77); book.WriteGrades(Console.Out); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Lowest", stats.LowestGrade); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); WriteResult(stats.Description, stats.LetterGrade); //keeps the program open so I can see the results. Console.ReadLine(); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.AddGrade(85); book.AddGrade(89.5f); GradeStatistics stats = book.ComputeStatistics(); GradeBook book2 = book; book2.AddGrade(75); }
static void Main(string[] args) { // Initialize the variable GradeBook book = new GradeBook(); book.NameChanged += OnNameChanged; // Assignment to the Name field in GradeBook.cs book.Name = "Kia's Grade Book"; book.Name = "Grade Book"; book.AddGrade(91); // Double to float book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); WriteResult("Lowest", stats.LowestGrade); }
static void Main(string[] args) { //SpeechSynthesizer synth = new SpeechSynthesizer(); // added an assembly reference for speech synthesizing //synth.Speak("Yo! This is a grade book program"); GradeBook book = new GradeBook(); // instantiating a new GradeBook book.NameChanged = new NameChangedDelegate(OnNameChanged); book.Name = "Victor's Grade Book!"; book.AddGrade(90); book.AddGrade(89.5f); // the 'f specifies to the compiler that this is a float' book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); // type casting... we tell compiler to convert this value to an int WriteResult("Lowest", stats.LowestGrade); }
static void Main(string[] args) { // Illustrate assemblies. //SpeechSynthesizer synth = new SpeechSynthesizer(); //synth.Speak("This is the grade book program"); GradeBook book = new GradeBook(); book.AddGrade(91); // add "f" to tell the compiler to treat as floating point number. book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HighestGrade); Console.WriteLine(stats.LowestGrade); //GradeBook book2 = new GradeBook(); //GradeBook book2 = book; //book2.AddGrade(75); }
static void Main(string[] args) { Console.WriteLine("Hej"); GradeBook book1 = new GradeBook(); book1.AddGrade(22f); List <float> allGrades = book1.getAllGrades(); Console.WriteLine(allGrades.First()); GradeStatistics stats = book1.ComputeGradeStatistics(); WriteResult("Average", stats.AverageGrade); }
static void Main(string[] args) { SpeechSynthesizer synth = new SpeechSynthesizer(); synth.Speak("Hello"); GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); book.WriteGrades(Console.Out); GradeStatistics stats = book.ComputeStatistics(); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", stats.HighestGrade); WriteResult("Lowest", stats.LowestGrade); WriteResult(stats.Description, stats.LetterGrade); Console.WriteLine("Press any key to exit..."); Console.ReadKey(); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.AddGrade(91.7f); book.AddGrade(67.7f); book.AddGrade(76.8f); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine("Average Grade: " + stats.AverageGrade); Console.WriteLine("Highest Grade " + stats.HighestGrade); Console.WriteLine("Lowest Grade " + stats.LowestGrade); //book.WriteGrades(Console.Out ); stats.RandomNumber = 56; Console.WriteLine(stats.RandomNumber); stats.testFullProp = 28; Console.ReadKey(); Console.WriteLine(stats.testFullProp); Console.ReadKey(); }
static void Main(string[] args) { SpeechSynthesizer synt = new SpeechSynthesizer(); synt.Speak("Hello, this is a C# course"); GradeBook book = new GradeBook(); book.NameChanged = new NameChangedDelegate(OnNameChanged); book.Name = "Xavier"; book.Name = "Joseph"; book.AddGrade(90); book.AddGrade(85.5f); book.AddGrade(75); GradeStatistics stats = book.computeStatistics(); WriteResult("Average", Convert.ToString(stats.AverageGrade) ); WriteResult("Highest", Convert.ToString( stats.HighestGrade)); WriteResult("Lowest", Convert.ToString( stats.LowestGrade)); WriteResult("Letter Grade", stats.LetterGrade); WriteResult("Description", stats.Description); }
static void Main(string[] args) { //Set default file name, set name if arg is present string readFile = "data.txt"; if (args.Length > 0) { readFile = args[0]; } //Create new gradebook object, set delegate and event GradeBook book = new GradeBook("Math") { NameChanged = new NameChangedDelegate(OnNameChanged), }; book.NewNameChanged += new NameChangedEventDelegate(OnNewNameChanged); //Read the specified file, place grades in gradebook try { using (FileStream stream = File.Open(@"" + readFile, FileMode.Open)) using (StreamReader reader = new StreamReader(stream)) { string line = reader.ReadLine(); while (line != null) { book.AddGrade(float.Parse(line)); line = reader.ReadLine(); } reader.Close(); stream.Close(); } } //Quit if file is not found catch (FileNotFoundException ex) { Console.WriteLine("File not found: " + ex.FileName); return; } //book.Print(); book.SetName("Science"); book.WriteGrades(Console.Out); book.ComputeStatistics().Print(); book.ComputeStatistics().Print(); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.NameChanged += OnNameChanged; book.Name = "Balach's Grade Book"; book.Name = "Grade Book"; book.Name = null; book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); WriteResult("Lowest", stats.LowestGrade); }
static void Main(string[] args) { SpeechSynthesizer synth = new SpeechSynthesizer(); //synth.Speak("Hello"); GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(89.5f); GradeBook book2 = book; book2.AddGrade(75); //book.NameChanged += new NameChangedDelegate(OnNameChanged); //book.NameChanged += new NameChangedDelegate(OnNameChanged2); book.NameChanged += BookOnNameChanged; book.name = "Chris' grades"; foreach (var aGrade in book.GetGrades()) { Console.WriteLine(aGrade); } Console.WriteLine(""); GradeStatistics stats = new GradeStatistics(book); stats.ComputeStatistics(); Console.WriteLine(book.name); Console.WriteLine($"Average: {stats.GetAverageGrade()}"); Console.WriteLine($"Highest: {stats.GetHighestGrade()}"); Console.WriteLine($"Lowest: {stats.GetLowestGrade()}"); }
static void Main(string[] args) { GradeBook g1 = new GradeBook(); GradeBook g2 = g1; SpeechSynthesizer synth = new SpeechSynthesizer(); // synth.Speak("Yuri, did you know C# can talk?"); GradeBook book = new GradeBook(); book.NameChanged += new NameChangedDelegate(OnNameChanged); book.Name = "Peters grade book"; book.Name = "Grade book"; book.Name = null; book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HigestGrade); Console.WriteLine(stats.LowestGrade); }
private static void OldMain() { Console.WriteLine("Grades project\n"); GradeBook book = new GradeBook(); book.NameChanged += OnNameChanged; book.Name = "First Gradebook"; book.Name = "Second Gradebook\n"; book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); WriteResult("Lowest", stats.LowestGrade); WriteResult(stats.Description, stats.LetterGrade); }
static void Main(string[] args) { //SpeechSynthesizer synth = new SpeechSynthesizer(); // added an assembly reference for speech synthesizing //synth.Speak("Yo! This is a grade book program"); GradeBook book = new GradeBook(); // instantiating a new GradeBook Console.WriteLine("Provide a GradeBook name..."); string GradeName = Console.ReadLine(); book.AddGrade(90); book.AddGrade(89.5f); // the 'f specifies to the compiler that this is a float' book.AddGrade(75); book.WriteGrades(Console.Out); // console.out refers to the output screen GradeStatistics stats = book.ComputeStatistics(); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", stats.HighestGrade); // type casting... we tell compiler to convert this value to an int WriteResult("Lowest", stats.LowestGrade); WriteResult(stats.Description, stats.LetterGrade); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(60); book.AddGrade(60.3); book.AddGrade(83.4); book.AddGrade(43.2); book.AddGrade(93.6); book.AddGrade(84.5); book.AddGrade(92.3); GradeStatistics stats = book.ComputeStatistics(); book.ComputeStatistics(); }
static void Main(string[] args) { GradeBook book = new GradeBook(); book.AddGrade(91); book.AddGrade(89.5f); GradeBook book2 = book; book2.AddGrade(75); book.AddGrade(90); GradeStats stats = book.ComputeStats(); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.LowestGrade); }
static void Main(string[] args) { //SpeechSynthesizer ss = new SpeechSynthesizer(); //ss.Speak("Dude. You've found the grade book program."); GradeBook book = new GradeBook(); book.AddGrade(991); book.AddGrade(89.5f); book.AddGrade(89.5f); book.AddGrade(89.5f); book.AddGrade(89.5f); book.AddGrade(89.5f); GradeStatistics stats = book.ComputeStatistics(); Console.WriteLine(stats.AverageGrade); Console.WriteLine(stats.HighestGrade); Console.WriteLine(stats.LowestGrade); //GradeBook book2 = book; //book2.AddGrade(123); }
private static void AddGrade(GradeBook book) { book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(58); }
static void Main(string[] args) { // need to add system.speech reference to project for this to work. // SpeechSynthesizer synth = new SpeechSynthesizer(); // synth.Speak("Hello! This is the gradebook program"); GradeBook book = new GradeBook(); /////////////////////////////////////////////////////////////// // need to initialize the delegate // why not just do this in constructor? // because you need the name of the method to be called. book.NameChanged += new NameChangedDelegate(OnNameChanged); /* * // this will overwrite the original, wont trigger both methods * book.NameChanged = new NameChangedDelegate(OnNameChanged2); * * // must do the += for it to do both * book.NameChanged += new NameChangedDelegate(OnNameChanged2); * * // as an event, you can add the same method twice * book.NameChanged += new NameChangedDelegate(OnNameChanged2); * * // as an event, you can also reduce some of the code * // The C# compiler is smart enough to know what this means * book.NameChanged += OnNameChanged2; * * // you can also do this to remove a reference: * // this only removes one of them, * // you would have to remove all 3 in this example to stop it * book.NameChanged -= new NameChangedDelegate(OnNameChanged2); */ /////////////////////////////////////////////////////////////// book.Name = "Katy's Grade Book"; book.Name = "Grade Book"; book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); GradeStatistics stats = book.ComputeStatistics(); //cw <tab><tab> creates a writeline // Console.WriteLine(stats.AverageGrade); // Console.WriteLine(stats.HighestGrade); // Console.WriteLine(stats.LowestGrade); // this shows how method overloading is used Console.WriteLine(book.Name); WriteResult("Average", stats.AverageGrade); WriteResult("Highest", (int)stats.HighestGrade); WriteResult("Lowest", stats.LowestGrade); // WriteResult("example of multi-parms", 1, 2, 3, 4); /////////////////////////////////////////////////////////////// /* * // this logic shows how pointers/references work for classes * GradeBook g1 = new GradeBook(); * GradeBook g2 = g1; * * g1 = new GradeBook(); // if this was not here, g2 would show g1's name * g1.Name = "Katy's grade book"; * Console.WriteLine(g2.Name); */ Console.ReadLine(); }
private static void AddGrades(GradeBook book) { book.AddGrade(65.5f); book.AddGrade(65.5f); book.AddGrade(10); }
private static void AddGrades(GradeBook book) { book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(30.3f); }
private static void addGradesToBook(GradeBook book) { book.AddGrade(78); book.AddGrade(99.444f); book.AddGrade(80); }
static void Main(string[] args) { //SpeechSynthesizer synth = new SpeechSynthesizer(); //synth.Speak("hello Tenzin Lunten, thank you for taking shower."); ////synth.Speak("Jack Jack and Mr. Incredible is angry now as Tenzin Lunten is not taking shower"); ////synth.Speak("It is on the verge of defeat"); System.Xml.XmlWriter sys; ////String d = "apple"; ////String e = "APPLE"; ////Boolean equals = d.Equals(e, StringComparison.CurrentCulture); ////Console.WriteLine(equals); //String line = " cr7"; //line = line.Trim(); // this thing doesnt modifies but returns a string. //Console.WriteLine(line); //DateTime dateNow = new DateTime(2018, 5, 14); //Console.WriteLine(dateNow); //dateNow = DateTime.Now; //Console.WriteLine(dateNow); //// stats.lowScore(); //Arrays(); ////Ctrl + k + c(comment) and Ctrl + k + u(uncomment) ////default is double and not float GradeBook book = new GradeBook(); book.AddGrade(91f); book.AddGrade(89.5f); book.AddGrade(75.5f); GradeStatistics stats = book.ComputeStatistics(); //book.NameChanged = new NameChangedDelegate(OnNameChanged); book.Name = "Tenzin's book"; book.NameChanged += OnNameChanged; book.NameChanged += OnNameChanged2; book.Name = "Tenzin's book 2"; //book.NameChanged = new NameChangedDelegate(OnNameChanged2); //An unknown or someone could do this code which would wipeout all three lines of code before it // So, we have to use events and to use it we just need to add event before the delegate name, then this // last code of initializing is not valid in events. // The correct way in event is to have two parameters: 1.senders object 2. encapsulated object Console.WriteLine("Average Score: " + stats.averageGrade); Console.WriteLine("Lowest Score: " + stats.lowestGrade); Console.WriteLine("Highest Score: " + stats.highestGrade); }
private static void AddingGrades(GradeBook book) { book.AddGrade(91); book.AddGrade(89.5f); book.AddGrade(75); }