public static void Main()
  {
   HomeworkAssignment course1 = new HomeworkAssignment();
   HomeworkAssignment course2 = new HomeworkAssignment();
   string entryString;
   int exercises;

   // Get info for first class
   Console.Write("What class do you have homework for? ");
   entryString = Console.ReadLine();
   course1.ClassName = entryString
   Console.Write("How many exercises must you complete? ");
   entryString = Console.ReadLine();
   exercises = Convert.ToInt32(entryString)
   course1.NumberOfExercises = eercises;
   
   // Get info for another class
   Console.Write("What class do you have homework for? ");
   entryString = ConsoleReadLine();
   course2.ClassName = entryString;
   Console.Write("How many exercises must you complete? );
   entryString = Console.ReadLine();
   exercises = Convert.ToInt32(entrystring);
   course2.NumberOfExercises = exercises;

   Console.WriteLine("You have {0} minutes of homework for {1}",
      course1.TimeToComplete, course1.ClassName);   
   Console.WriteLine("and {0} more minutes for {1}",
      course2.TimeToComplete,course2.ClassName);
  }
Beispiel #2
0
    public static void NineOne()
    {
        HomeworkAssignment course1 = new HomeworkAssignment();
        HomeworkAssignment course2 = new HomeworkAssignment();
        string             entryString;
        int exercises;

        // Get info for first class
        Write("What class do you have homework for? ");
        entryString       = ReadLine();
        course1.ClassName = entryString;
        Write("How many exercises must you complete? ");
        entryString = ReadLine();
        int.TryParse(entryString, out exercises);
        course1.NumberOfExercises = exercises;

        // Get info for another class
        Write("What class do you have homework for? ");
        entryString       = ReadLine();
        course2.ClassName = entryString;
        Write("How many exercises must you complete? ");
        entryString = ReadLine();
        int.TryParse(entryString, out exercises);
        course2.NumberOfExercises = exercises;

        WriteLine("You have {0} minutes of homework for {1}",
                  course1.TimeToComplete, course1.ClassName);
        WriteLine("and {0} more minutes for {1}",
                  course2.TimeToComplete, course2.ClassName);
    }
Beispiel #3
0
    public static void NineOne()
    {
        HomeworkAssignment course1 = new HomeworkAssignment();
        HomeworkAssignment course2 = new HomeworkAssignment();
        string             entryString;
        int exercises;

        // Get info for first class
        Write("What class do you have homework for? ");
        entryString       = ReadLine();  //ch to entrystring
        course1.ClassName = entryString; //ch lower c to upper C
        Write("How many exercises must you complete? ");
        entryString = ReadLine();
        int.TryParse(entryString, out exercises); //added out keyword
        course1.NumberOfExercises = exercises;    //reversed exer & c1.numOfEx

        // Get info for another class
        Write("What class do you have homework for? ");
        entryString       = ReadLine();
        course2.ClassName = entryString; //ch lower c to upper+ corr name for entryString..MUST CHANGE TO COURSE1.CLASSNAME!!!
        Write("How many exercises must you complete? ");
        entryString = ReadLine();
        int.TryParse(entryString, out exercises);//ch to Int.tryparse
        course2.NumberOfExercises = exercises;

        WriteLine("You have {0} minutes of homework for {1}",
                  course1.TimeToComplete, course1.ClassName); //ch lower t to upper T
        WriteLine("and {0} more minutes for {1}",
                  course2.TimeToComplete, course2.ClassName); //ch lower t to upper T

        ReadLine();
    }
        public void Homework_HasRequiredProperties()
        {
            Type type = typeof(HomeworkAssignment);
            HomeworkAssignment assignment = (HomeworkAssignment)Activator.CreateInstance(type, 100);

            PropertyInfo[] properties = type.GetProperties();

            PropertyInfo prop = FindPropertyByName(properties, "TotalMarks");

            Assert.IsNotNull(prop, "You do not have the TotalMarks property");
            Assert.IsTrue(prop.CanWrite, "TotalMarks property needs a set accessor.");
            Assert.IsTrue(prop.CanRead, "TotalMarks property needs a get accessor.");

            prop = FindPropertyByName(properties, "PossibleMarks");
            Assert.IsNotNull(prop, "You do not have the PossibleMarks property");
            Assert.IsFalse(prop.CanWrite, "PossibleMarks property should not have a set accessor.");
            Assert.IsTrue(prop.CanRead, "PossibleMarks property needs a get accessor.");

            prop = FindPropertyByName(properties, "SubmitterName");
            Assert.IsNotNull(prop, "You do not have the SubmitterName property");
            Assert.IsTrue(prop.CanWrite, "SubmitterName property needs a set accessor.");
            Assert.IsTrue(prop.CanRead, "SubmitterName property needs a get accessor.");

            prop = FindPropertyByName(properties, "LetterGrade");
            Assert.IsNotNull(prop, "You do not have the LetterGrade property");
            Assert.IsFalse(prop.CanWrite, "LetterGrade property should not have a set accessor.");
            Assert.IsTrue(prop.CanRead, "LetterGrade property needs a get accessor.");
        }
        public void HomeworkAssignment_Constructor()
        {
            Type type = typeof(HomeworkAssignment);
            HomeworkAssignment assignment = (HomeworkAssignment)Activator.CreateInstance(type, 100, "Default Name");

            PropertyInfo prop = FindPropertyByName(type.GetProperties(), "PossibleMarks");

            Assert.AreEqual(100, prop.GetValue(assignment), "Passed 100 into constructor and expected PossibleMarks property to return 100");
        }
Beispiel #6
0
        public void ScoringAssignment(int scoreReceived, string expectedGrade)
        {
            // Assert
            HomeworkAssignment ha = new HomeworkAssignment(100, "Henry Edwards");

            // Act
            ha.TotalMarks = scoreReceived;

            // Assert
            Assert.AreEqual(expectedGrade, ha.LetterGrade);
        }
Beispiel #7
0
        public void WhenCreatingNewAssignment_ShouldSaveConstructorProperties()
        {
            // Arrange
            // No arrangment necessary

            // Act
            // Create a HomeworkAssignment object
            HomeworkAssignment hw = new HomeworkAssignment(80, "Mike");

            // Assert
            Assert.AreEqual("Mike", hw.SubmitterName, "The submitter name was not properly set in the HomeworkAssignment constructor");
            Assert.AreEqual(80, hw.PossibleMarks, "The possible marks property was not properly set in the HomeworkAssignment constructor");
        }
Beispiel #8
0
        public void WhenTotalMarksGreaterThanPossibleMarks_ShouldGiveAnA()
        {
            // Arrange
            // Create a new homework assignment
            HomeworkAssignment hw = new HomeworkAssignment(100, "Mike");

            // Act
            // Set the total marks > possible marks
            hw.TotalMarks = 102;

            // Assert
            // Verify that > 100% gives an A
            Assert.AreEqual("A", hw.LetterGrade,
                            "Did not properly assign letter grade A when total marks is greater than possible marks");
        }
Beispiel #9
0
        public void LetterGradeTest(int possibleMarks, int totalMarks, string expectedLetterGrade)
        {
            // Arrange
            // Create a new homework assignment with the proper possible marks
            HomeworkAssignment hw = new HomeworkAssignment(possibleMarks, "TEST");

            // Act
            // Set the total marks
            hw.TotalMarks = totalMarks;

            // Assert
            // Compare the letter grade to the expected letter grade passed in
            Assert.AreEqual(expectedLetterGrade, hw.LetterGrade,
                            $"Did not properly set the letter grade to {expectedLetterGrade} for a score of {totalMarks} / {possibleMarks}."
                            );
        }
Beispiel #10
0
        static void Main(string[] args)
        {
            HomeworkAssignment hw;

            // Make sure the constructor works properly to set Properties
            hw = new HomeworkAssignment(200, "Mike");
            Console.WriteLine($"Expected property SubmitterName to be 'Mike', actual value was '{hw.SubmitterName}'");
            Console.WriteLine($"Expected property PossibleMarks to be 200, actual value was '{hw.PossibleMarks}'");

            // Test the 90% is an A
            hw            = new HomeworkAssignment(100, "Mike");
            hw.TotalMarks = 90;
            Console.WriteLine($"Expected 90% to be an 'A', actual grade was '{hw.LetterGrade}'");

            //

            Console.ReadKey();
        }
Beispiel #11
0
        public void Homework_HasRequiredProperties()
        {
            Type type = typeof(HomeworkAssignment);
            HomeworkAssignment assignment = (HomeworkAssignment)Activator.CreateInstance(type, 100, "Default Name");

            PropertyInfo[] properties = type.GetProperties();

            PropertyInfo prop = FindPropertyByName(properties, "TotalMarks");

            PropertyValidator.ValidateReadWrite(prop, "TotalMarks", typeof(int));

            prop = FindPropertyByName(properties, "PossibleMarks");
            PropertyValidator.ValidateReadOnly(prop, "PossibleMarks", typeof(int));

            prop = FindPropertyByName(properties, "SubmitterName");
            PropertyValidator.ValidateReadOnly(prop, "SubmitterName", typeof(string));


            prop = FindPropertyByName(properties, "LetterGrade");
            PropertyValidator.ValidateReadOnly(prop, "LetterGrade", typeof(string));
        }
        public void HomeworkAssignment_LetterGradeTests()
        {
            Type type = typeof(HomeworkAssignment);
            HomeworkAssignment assignment = (HomeworkAssignment)Activator.CreateInstance(type, 100, "Default Name");

            PropertyInfo letterProp = FindPropertyByName(type.GetProperties(), "LetterGrade");

            PropertyInfo prop = FindPropertyByName(type.GetProperties(), "EarnedMarks");

            prop.SetValue(assignment, 91);
            Assert.AreEqual("A", letterProp.GetValue(assignment), "Expected A for score of 91%");

            prop.SetValue(assignment, 81);
            Assert.AreEqual("B", letterProp.GetValue(assignment), "Expected B for score of 81%");

            prop.SetValue(assignment, 71);
            Assert.AreEqual("C", letterProp.GetValue(assignment), "Expected C for score of 71%");

            prop.SetValue(assignment, 61);
            Assert.AreEqual("D", letterProp.GetValue(assignment), "Expected C for score of 61%");

            prop.SetValue(assignment, 51);
            Assert.AreEqual("F", letterProp.GetValue(assignment), "Expected C for score of 51%");
        }
Beispiel #13
0
 public void Insert(HomeworkAssignment homeworkAssignment)
 {
     this.homeworkAssignmentRepository.Insert(homeworkAssignment);
 }
Beispiel #14
0
 public void Edit(HomeworkAssignment homeworkAssignment)
 {
     this.homeworkAssignmentRepository.Update(homeworkAssignment);
 }