/// <summary> /// Accept method for the input data visitor. /// </summary> /// <param name="visitor">Visitor.</param> public override void Accept(IVisitor visitor) { visitor.Visit(this); Term1.Accept(visitor); Term2.Accept(visitor); visitor.PostVisit(this); }
private void AddCourseToTerm() { Console.WriteLine("What's the name of this course?"); String newCourseName = Console.ReadLine(); newCourseName.ToLower(); Course newUserCourse = new Course(newCourseName); try { Term1.AddCourse(newUserCourse); } catch (PreExistingCourseException) { Console.WriteLine("This course already exists in this term! Please try again..."); } Console.WriteLine("The course has been added!"); DisplayCourseOptions(); String key = Console.ReadLine(); key.ToUpper(); Course1 = newUserCourse; if (key.Equals("J")) { Process(key); } }
/// <summary> /// Adds its two terms together, evaluating those two terms as necessary. /// </summary> /// <param name="rng">The rng to use, passed to other terms.</param> /// <returns>The result of adding <see cref="Term1"/> and <see cref="Term2"/>.</returns> public int GetResult(IGenerator rng) { return(Term1.GetResult(rng) + Term2.GetResult(rng)); }
/// <summary> /// Divides the first term by the second, evaluating those two terms as necessary. /// </summary> /// <param name="rng">The rng to used -- passed to other terms.</param> /// <returns>The result of evaluating <see cref="Term1"/> / <see cref="Term2"/>.</returns> public int GetResult(IGenerator rng) { return((int)Math.Round((double)Term1.GetResult(rng) / Term2.GetResult(rng))); }
/// <summary> /// Subtracts the second term from the first, evaluating those two terms as necessary. /// </summary> /// <param name="rng">The rng to used -- passed to other terms.</param> /// <returns>The result of evaluating Term1 - Term2.</returns> public int GetResult(IRandom rng) { return(Term1.GetResult(rng) - Term2.GetResult(rng)); }
/// <summary> /// Divides the first term by the second, evaluating those two terms as necessary. /// </summary> /// <param name="rng">The rng to used -- passed to other terms.</param> /// <returns>The result of evaluating Term1 / Term2.</returns> public int GetResult(IRandom rng) { return((int)Math.Round((double)Term1.GetResult(rng) / Term2.GetResult(rng))); }