/// <summary> /// Figure out which angles we can choose from before the window is shown. /// </summary> protected override void OnShow() { List <GroundedClause> givens = new List <GroundedClause>(); //Populate list with applicable givens foreach (GroundedClause gc in currentGivens) { RightAngle ra = gc as RightAngle; if (ra != null) { givens.Add(ra); } } List <Angle> rightAngles = new List <Angle>(); //Populate list with possible choices foreach (Angle a in parser.backendParser.implied.angles) { if (a.measure == 90) { RightAngle ra = new RightAngle(a); if (!StructurallyContains(givens, ra)) { rightAngles.Add(ra); } } } options.ItemsSource = null; //Makes sure the box is graphically updated. options.ItemsSource = rightAngles; }
// // DO NOT generate a new clause, instead, report the result and generate all applicable // private static List <EdgeAggregator> StrengthenToRightTriangle(Triangle tri, RightAngle ra, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // This angle must belong to this triangle. if (!tri.HasAngle(ra)) { return(newGrounded); } // Strengthen the old triangle to a right triangle Strengthened newStrengthened = new Strengthened(tri, new RightTriangle(tri)); tri.SetProvenToBeRight(); // Hypergraph List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(tri); antecedent.Add(original); newGrounded.Add(new EdgeAggregator(antecedent, newStrengthened, annotation)); return(newGrounded); }
public static List <EdgeAggregator> InstantiateFromRightAngle(GroundedClause clause) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); RightAngle ra = null; if (clause is Strengthened) { ra = ((clause as Strengthened).strengthened) as RightAngle; } else if (clause is RightAngle) { ra = clause as RightAngle; } else { return(newGrounded); } // Strengthening may be something else if (ra == null) { return(newGrounded); } GeometricAngleEquation angEq = new GeometricAngleEquation(ra, new NumericValue(90)); List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(clause); newGrounded.Add(new EdgeAggregator(antecedent, angEq, defAnnotation)); return(newGrounded); }
private static List <EdgeAggregator> InstantiateToSquare(Rhombus rhombus, RightAngle ra, GroundedClause originalRhom, GroundedClause originalRightAngle) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // Does this right angle apply to this quadrilateral? if (!rhombus.HasAngle(ra)) { return(newGrounded); } // // Create the new Square object // Strengthened newSquare = new Strengthened(rhombus, new Square(rhombus)); // For hypergraph List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(originalRhom); antecedent.Add(originalRightAngle); newGrounded.Add(new EdgeAggregator(antecedent, newSquare, annotation)); return(newGrounded); }
public void RightAngleTest(double side1, double side2, double area, double peri) { right = new RightAngle("Blue", side1, side2, 0); right.SetHypotenuse(); Assert.AreEqual(area, right.GetArea()); Assert.AreEqual(peri, right.GetPerimeter()); }
public void RightAngleTest(int width, int height, double area, double perimeter) { RightAngle rightAngle = new RightAngle(width, height); rightAngle.SetHypotenuse(); Assert.AreEqual(area, Math.Round(rightAngle.GetArea(), 2)); Assert.AreEqual(perimeter, Math.Round(rightAngle.GetPerimeter(), 2)); }
// // Implements 'transitivity' with right angles; that is, we may know two angles are congruent and if one is a right angle, the other is well // // Congruent(Angle(A, B, C), Angle(D, E, F), RightAngle(A, B, C) -> RightAngle(D, E, F) // public static List <EdgeAggregator> InstantiateToRightAngle(RightAngle ra, CongruentAngles cas, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // The congruent must have the given angle in order to generate if (!cas.HasAngle(ra)) { return(newGrounded); } Angle toBeRight = cas.OtherAngle(ra); Strengthened newRightAngle = new Strengthened(toBeRight, new RightAngle(toBeRight)); List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(original); antecedent.Add(cas); newGrounded.Add(new EdgeAggregator(antecedent, newRightAngle, transAnnotation)); return(newGrounded); }
public void Init() { s1 = new Square("white", 5); s2 = new Square("white", 15); s3 = new Square("white", 7); r1 = new Rectangle("white", 5, 10); r2 = new Rectangle("white", 4, 6); r3 = new Rectangle("white", 9, 7); c1 = new Circle("White", 5); c2 = new Circle("White", 15); c3 = new Circle("White", 7); e1 = new Equilateral("White", 5); e2 = new Equilateral("White", 15); e3 = new Equilateral("White", 7); ra1 = new RightAngle("White", 5, 10); ra2 = new RightAngle("White", 4, 6); ra3 = new RightAngle("White", 9, 7); }
public static List <EdgeAggregator> InstantiateToPerpendicular(GroundedClause clause) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); if (clause is Intersection) { // Since we receive intersections right away in the instantiation process, just store the intersections candidateIntersections.Add(clause as Intersection); } else if (clause is RightAngle) { RightAngle ra = clause as RightAngle; foreach (Intersection inter in candidateIntersections) { newGrounded.AddRange(InstantiateToPerpendicular(inter, ra, clause)); } } else if (clause is Strengthened) { Strengthened streng = clause as Strengthened; // Only intrerested in right angles if (!(streng.strengthened is RightAngle)) { return(newGrounded); } foreach (Intersection inter in candidateIntersections) { newGrounded.AddRange(InstantiateToPerpendicular(inter, streng.strengthened as RightAngle, clause)); } } return(newGrounded); }
private static List <EdgeAggregator> InstantiateToSquare(GroundedClause clause) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); if (clause is Rhombus) { Rhombus newRhom = clause as Rhombus; // We don't want to strengthen a Square to a square. if (clause is Square) { return(newGrounded); } foreach (RightAngle rightAngle in candidateRightAngle) { newGrounded.AddRange(InstantiateToSquare(newRhom, rightAngle, newRhom, rightAngle)); } foreach (Strengthened rightStreng in candidateStrengRightAngle) { newGrounded.AddRange(InstantiateToSquare(newRhom, rightStreng.strengthened as RightAngle, newRhom, rightStreng)); } candidateRhombus.Add(newRhom); } else if (clause is Strengthened) { Strengthened streng = clause as Strengthened; if (streng.strengthened is Rhombus) { // We don't want to strengthen a Square to a square. if (streng.strengthened is Square) { return(newGrounded); } foreach (RightAngle rightAngle in candidateRightAngle) { newGrounded.AddRange(InstantiateToSquare(streng.strengthened as Rhombus, rightAngle, streng, rightAngle)); } foreach (Strengthened rightStreng in candidateStrengRightAngle) { newGrounded.AddRange(InstantiateToSquare(streng.strengthened as Rhombus, rightStreng.strengthened as RightAngle, streng, rightStreng)); } candidateStrengRhombus.Add(streng); } else if (streng.strengthened is RightAngle) { foreach (Rhombus oldRhom in candidateRhombus) { newGrounded.AddRange(InstantiateToSquare(oldRhom, streng.strengthened as RightAngle, oldRhom, streng)); } foreach (Strengthened strengRhom in candidateStrengRhombus) { newGrounded.AddRange(InstantiateToSquare(strengRhom.strengthened as Rhombus, streng.strengthened as RightAngle, strengRhom, streng)); } candidateStrengRightAngle.Add(streng); } else { return(newGrounded); } } else if (clause is RightAngle) { RightAngle rightAngle = clause as RightAngle; foreach (Rhombus oldRhom in candidateRhombus) { newGrounded.AddRange(InstantiateToSquare(oldRhom, rightAngle, oldRhom, rightAngle)); } foreach (Strengthened strengRhom in candidateStrengRhombus) { newGrounded.AddRange(InstantiateToSquare(strengRhom.strengthened as Rhombus, rightAngle, strengRhom, rightAngle)); } candidateRightAngle.Add(rightAngle); } return(newGrounded); }
public static List <EdgeAggregator> InstantiateToRightAngle(GroundedClause clause) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); if (clause is AngleEquation) { AngleEquation eq = clause as AngleEquation; //Filter for acceptable equations - both sides atomic int atomicity = eq.GetAtomicity(); if (atomicity != Equation.BOTH_ATOMIC) { return(newGrounded); } //Check that the terms equate an angle to a measure List <GroundedClause> lhs = eq.lhs.CollectTerms(); List <GroundedClause> rhs = eq.rhs.CollectTerms(); Angle angle = null; NumericValue value = null; if (lhs[0] is Angle && rhs[0] is NumericValue) { angle = lhs[0] as Angle; value = rhs[0] as NumericValue; } else if (rhs[0] is Angle && lhs[0] is NumericValue) { angle = rhs[0] as Angle; value = lhs[0] as NumericValue; } else { return(newGrounded); } //Verify that the angle is a right angle if (!Utilities.CompareValues(value.DoubleValue, 90.0)) { return(newGrounded); } Strengthened newRightAngle = new Strengthened(angle, new RightAngle(angle)); List <GroundedClause> antecedent = Utilities.MakeList <GroundedClause>(clause); newGrounded.Add(new EdgeAggregator(antecedent, newRightAngle, defAnnotation)); return(newGrounded); } else if (clause is CongruentAngles) { CongruentAngles cas = clause as CongruentAngles; // Not interested in reflexive relationships in this case if (cas.IsReflexive()) { return(newGrounded); } foreach (RightAngle ra in candidateRightAngles) { newGrounded.AddRange(InstantiateToRightAngle(ra, cas, ra)); } foreach (Strengthened streng in candidateStrengthened) { newGrounded.AddRange(InstantiateToRightAngle(streng.strengthened as RightAngle, cas, streng)); } candidateCongruentAngles.Add(clause as CongruentAngles); } else if (clause is RightAngle) { RightAngle ra = clause as RightAngle; foreach (CongruentAngles oldCas in candidateCongruentAngles) { newGrounded.AddRange(InstantiateToRightAngle(ra, oldCas, ra)); } candidateRightAngles.Add(ra); } else if (clause is Strengthened) { Strengthened streng = clause as Strengthened; // Only intrerested in right angles if (!(streng.strengthened is RightAngle)) { return(newGrounded); } foreach (CongruentAngles oldCas in candidateCongruentAngles) { newGrounded.AddRange(InstantiateToRightAngle(streng.strengthened as RightAngle, oldCas, streng)); } candidateStrengthened.Add(streng); } return(newGrounded); }
public static List <EdgeAggregator> InstantiateToComplementary(GroundedClause clause) { annotation.active = EngineUIBridge.JustificationSwitch.COMPLEMENTARY_DEFINITION; List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); if (clause is AngleEquation) { AngleEquation eq = clause as AngleEquation; // // Filter only acceptable equations; one side has two values, the other one // // Check basic size of the sides int atomicity = eq.GetAtomicity(); if (atomicity == Equation.BOTH_ATOMIC || atomicity == Equation.NONE_ATOMIC) { return(newGrounded); } // Now check more involved cardinalities of each side KeyValuePair <int, int> cards = eq.GetCardinalities(); if (!(cards.Key == 1 && cards.Value == 2) && !(cards.Key == 2 && cards.Value == 1)) { return(newGrounded); } List <GroundedClause> terms = cards.Key == 2 ? eq.lhs.CollectTerms() : eq.rhs.CollectTerms(); List <GroundedClause> singleton = cards.Key == 1 ? eq.lhs.CollectTerms() : eq.rhs.CollectTerms(); // Coefficients need to be 1 foreach (GroundedClause gc in terms) { if (gc.multiplier != 1) { return(newGrounded); } } // Require the constant to be 90 NumericValue numeral = singleton[0] as NumericValue; if (numeral == null || Utilities.CompareValues(numeral.IntValue, 90)) { return(newGrounded); } // Require adjacent angles Angle angle1 = terms[0] as Angle; Angle angle2 = terms[1] as Angle; if (angle1.IsAdjacentTo(angle2) == null) { return(newGrounded); } foreach (RightAngle ra in candidateRightAngles) { newGrounded.AddRange(InstantiateToComplementary(eq, ra, ra)); } foreach (Strengthened streng in candidateStrengthened) { newGrounded.AddRange(InstantiateToComplementary(eq, streng.strengthened as RightAngle, streng)); } candidateAngleEquations.Add(eq); } else if (clause is RightAngle) { RightAngle newRa = clause as RightAngle; foreach (AngleEquation eq in candidateAngleEquations) { newGrounded.AddRange(InstantiateToComplementary(eq, newRa, newRa)); } candidateRightAngles.Add(newRa); } else if (clause is Strengthened) { Strengthened newStreng = clause as Strengthened; if (!(newStreng.strengthened is RightAngle)) { return(newGrounded); } foreach (AngleEquation eq in candidateAngleEquations) { newGrounded.AddRange(InstantiateToComplementary(eq, newStreng.strengthened as RightAngle, newStreng)); } candidateStrengthened.Add(newStreng); } return(newGrounded); }
static void Main(string[] args) { string choice = ""; while (choice.ToLower() != "f") { Console.WriteLine("---------------------------------"); Console.WriteLine("What would you like to create?"); Console.WriteLine("a. Square"); Console.WriteLine("b. Rectangle"); Console.WriteLine("c. Right Angle Triangle"); Console.WriteLine("d. Equilateral Triangle"); Console.WriteLine("e. Circle"); Console.WriteLine("f. Exit"); Console.WriteLine(); Console.Write("Selection: "); choice = Console.ReadLine(); try { Console.WriteLine(); if (choice.ToLower() == "a") { Console.WriteLine("---------------------------------"); Console.WriteLine("Create Square:"); Console.Write("Input Colour: "); string colour = Console.ReadLine(); Console.Write("Input Side Length: "); string sideinput = Console.ReadLine(); if (sideinput.Contains(".")) { throw new DecimalException("Please input whole number"); } int side = int.Parse(sideinput); Square newSquare = new Square(side); newSquare.Colour = colour; Console.WriteLine(); Console.WriteLine("Shape Created"); } else if (choice.ToLower() == "b") { Console.WriteLine("Create Rectangle:"); Console.Write("Input Colour: "); string colour = Console.ReadLine(); Console.Write("Input Side Length 1: "); string side1input = Console.ReadLine(); if (side1input.Contains(".")) { throw new DecimalException("Please input whole number"); } int side1 = int.Parse(side1input); Console.Write("Input Side Length 2: "); string side2input = Console.ReadLine(); if (side2input.Contains(".")) { throw new DecimalException("Please input whole number"); } int side2 = int.Parse(side2input); Rectangle newRectangle = new Rectangle(side1, side2); newRectangle.Colour = colour; Console.WriteLine(); Console.WriteLine("Shape Created"); } else if (choice.ToLower() == "c") { Console.WriteLine("Create Right Angle Triangle:"); Console.Write("Input Colour: "); string colour = Console.ReadLine(); Console.Write("Input Side Length 1: "); string side1input = Console.ReadLine(); if (side1input.Contains(".")) { throw new DecimalException("Please input whole number"); } int side1 = int.Parse(side1input); Console.Write("Input Side Length 2: "); string side2input = Console.ReadLine(); if (side2input.Contains(".")) { throw new DecimalException("Please input whole number"); } int side2 = int.Parse(side2input); RightAngle newRightAngle = new RightAngle(side1, side2); newRightAngle.SetHypotenuse(); newRightAngle.Colour = colour; Console.WriteLine(); Console.WriteLine("Shape Created"); } else if (choice.ToLower() == "d") { Console.WriteLine("---------------------------------"); Console.WriteLine("Create Equilateral Triangle:"); Console.Write("Input Colour: "); string colour = Console.ReadLine(); Console.Write("Input Side Length: "); string sideinput = Console.ReadLine(); if (sideinput.Contains(".")) { throw new DecimalException("Please input whole number"); } int side = int.Parse(sideinput); Equilateral newEquilateral = new Equilateral(side); newEquilateral.Colour = colour; Console.WriteLine(); Console.WriteLine("Shape Created"); } else if (choice.ToLower() == "e") { Console.WriteLine("---------------------------------"); Console.WriteLine("Create Circle:"); Console.Write("Input Colour: "); string colour = Console.ReadLine(); Console.Write("Input Radius: "); string radiusinput = Console.ReadLine(); if (radiusinput.Contains(".")) { throw new DecimalException("Please input whole number"); } int radius = int.Parse(radiusinput); Circle newCircle = new Circle(); newCircle.Radius = radius; newCircle.Colour = colour; Console.WriteLine(); Console.WriteLine("Shape Created"); } else { throw new InvalidInputException("Please choose a valid option"); } } catch (FormatException e) { Console.WriteLine("Error: " + e.Message); } catch (DecimalException e) { Console.WriteLine("Error: " + e.Message); } catch (InvalidInputException e) { Console.WriteLine("Error: " + e.Message); } finally { Console.WriteLine(); } } }
// // RightAngle(A, B, C), Angle(A, B, X) + Angle(X, B, C) = 90 -> Complementary(Angle(A, B, X), Angle(X, B, C)) // public static List <EdgeAggregator> InstantiateToComplementary(AngleEquation eq, RightAngle ra, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // // Acquire the two angles from the equation // KeyValuePair <int, int> cards = eq.GetCardinalities(); List <GroundedClause> terms = cards.Key == 2 ? eq.lhs.CollectTerms() : eq.rhs.CollectTerms(); List <GroundedClause> singleton = cards.Key == 1 ? eq.lhs.CollectTerms() : eq.rhs.CollectTerms(); Angle angle1 = terms[0] as Angle; Angle angle2 = terms[1] as Angle; // Create the resultant angle to compare to the input right angle Segment shared = angle1.IsAdjacentTo(angle2); if (!ra.HasSegment(angle1.OtherRayEquates(shared)) || !ra.HasSegment(angle2.OtherRayEquates(shared))) { return(newGrounded); } // Success, we have correspondence Complementary comp = new Complementary(angle1, angle2); List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(original); newGrounded.Add(new EdgeAggregator(antecedent, comp, annotation)); return(newGrounded); }
public void RightAngleTest(double sideLength1, double sideLength2, double area, double perimeter) { var rightAngle = new RightAngle(sideLength1, sideLength2); AssertCalc(rightAngle, area, perimeter); }
static void Main(string[] args) { while (true) { Console.WriteLine("1. Create Square"); Console.WriteLine("2. Create Rectangle"); Console.WriteLine("3. Create Equilateral Triangle"); Console.WriteLine("4. Create Right Angle Triangle"); Console.WriteLine("5. Create Circle"); Console.WriteLine("6. Exit"); Console.Write("Choose an option: "); var choiceText = Console.ReadLine(); int choice; try { choice = int.Parse(choiceText); } catch (FormatException) { Console.WriteLine("Please enter a number"); continue; } switch (choice) { case 1: { Console.Write("Enter colour: "); var colour = Console.ReadLine(); var sideLength1 = RetrieveLength("size"); var square = new Square(sideLength1); square.Colour = colour; Console.WriteLine("Successfully created a Square"); } break; case 2: { Console.Write("Enter colour: "); var colour = Console.ReadLine(); var sideLength1 = RetrieveLength("first side length"); var sideLength2 = RetrieveLength("second side length"); var rectangle = new Rectangle(sideLength1, sideLength2); rectangle.Colour = colour; Console.WriteLine("Successfully created a Rectangle"); } break; case 3: { Console.Write("Enter colour: "); var colour = Console.ReadLine(); var sideLength1 = RetrieveLength("side length"); var equilateral = new Equilateral(sideLength1); equilateral.Colour = colour; Console.WriteLine("Successfully created an Equilateral Triangle"); } break; case 4: { Console.Write("Enter colour: "); var colour = Console.ReadLine(); var sideLength1 = RetrieveLength("first side length"); var sideLength2 = RetrieveLength("second side length"); var rightAngle = new RightAngle(sideLength1, sideLength2); rightAngle.Colour = colour; Console.WriteLine("Successfully created a Right Angle Triangle"); } break; case 5: { Console.Write("Enter colour: "); var colour = Console.ReadLine(); var radius = RetrieveLength("radius"); var circle = new Circle(); circle.Radius = radius; circle.Colour = colour; Console.WriteLine("Successfully created a Circle"); } break; case 6: { return; } break; default: { Console.WriteLine($"Option {choice} not found"); } break; } } }
public void GetAreaTest(double input1, double input2, double expected) { ri = new RightAngle(colour, input1, input2); Assert.AreEqual(expected, ri.GetArea()); }
private static List <EdgeAggregator> InstantiateToRectangle(GroundedClause clause) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); if (clause is Parallelogram) { Parallelogram newPara = clause as Parallelogram; // Don't strengthen a Rectangle to a Rectangle if (newPara is Rectangle) { return(newGrounded); } foreach (RightAngle rightAngle in candidateRightAngle) { newGrounded.AddRange(InstantiateToRectangle(newPara, rightAngle, newPara, rightAngle)); } foreach (Strengthened rightStreng in candidateStrengRightAngle) { newGrounded.AddRange(InstantiateToRectangle(newPara, rightStreng.strengthened as RightAngle, newPara, rightStreng)); } candidateParallelogram.Add(newPara); } else if (clause is Strengthened) { Strengthened streng = clause as Strengthened; if (streng.strengthened is Parallelogram) { // Don't strengthen a Rectangle to a Rectangle if (streng.strengthened is Rectangle || streng.strengthened is Square) { return(newGrounded); } foreach (RightAngle rightAngle in candidateRightAngle) { newGrounded.AddRange(InstantiateToRectangle(streng.strengthened as Parallelogram, rightAngle, streng, rightAngle)); } foreach (Strengthened rightStreng in candidateStrengRightAngle) { newGrounded.AddRange(InstantiateToRectangle(streng.strengthened as Parallelogram, rightStreng.strengthened as RightAngle, streng, rightStreng)); } candidateStrengParallelogram.Add(streng); } else if (streng.strengthened is RightAngle) { foreach (Parallelogram oldPara in candidateParallelogram) { newGrounded.AddRange(InstantiateToRectangle(oldPara, streng.strengthened as RightAngle, oldPara, streng)); } foreach (Strengthened strengPara in candidateStrengParallelogram) { newGrounded.AddRange(InstantiateToRectangle(strengPara.strengthened as Parallelogram, streng.strengthened as RightAngle, strengPara, streng)); } candidateStrengRightAngle.Add(streng); } else { return(newGrounded); } } else if (clause is RightAngle) { RightAngle rightAngle = clause as RightAngle; foreach (Parallelogram oldPara in candidateParallelogram) { newGrounded.AddRange(InstantiateToRectangle(oldPara, rightAngle, oldPara, rightAngle)); } foreach (Strengthened strengPara in candidateStrengParallelogram) { newGrounded.AddRange(InstantiateToRectangle(strengPara.strengthened as Parallelogram, rightAngle, strengPara, rightAngle)); } candidateRightAngle.Add(rightAngle); } return(newGrounded); }
private static List <EdgeAggregator> InstantiateToRectangle(Parallelogram parallelogram, RightAngle ra, GroundedClause originalPara, GroundedClause originalRightAngle) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // Does this right angle apply to this quadrilateral? if (!parallelogram.HasAngle(ra)) { return(newGrounded); } // // Create the new Rectangle object // Strengthened newRectangle = new Strengthened(parallelogram, new Rectangle(parallelogram)); // For hypergraph List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(originalPara); antecedent.Add(originalRightAngle); newGrounded.Add(new EdgeAggregator(antecedent, newRectangle, annotation)); return(newGrounded); }
private static List <EdgeAggregator> InstantiateToPerpendicular(Intersection inter, RightAngle ra, GroundedClause original) { List <EdgeAggregator> newGrounded = new List <EdgeAggregator>(); // This angle must apply to this intersection (same vertex as well as the segments inducing this angle) if (!inter.InducesNonStraightAngle(ra)) { return(newGrounded); } // We are strengthening an intersection to a perpendicular 'labeling' Strengthened streng = new Strengthened(inter, new Perpendicular(inter)); List <GroundedClause> antecedent = new List <GroundedClause>(); antecedent.Add(original); antecedent.Add(inter); newGrounded.Add(new EdgeAggregator(antecedent, streng, annotation)); return(newGrounded); }
static void Main(string[] args) { bool running = true; while (running) { Console.Clear(); Console.WriteLine("Make a Shape!"); Console.WriteLine("1. Square"); Console.WriteLine("2. Rectangle"); Console.WriteLine("3. Equilateral Triangle"); Console.WriteLine("4. Right Angle Triangle"); Console.WriteLine("5. Circle"); Console.WriteLine("e. Exit"); switch (Console.ReadLine()) { case "1": { Console.Clear(); Console.WriteLine("You are making a square"); Console.WriteLine("What colour is it?"); string colour = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You are making a {colour} square"); Console.WriteLine("What is its side length?"); double side = GetNum(); Square square = new Square(side); square.Colour = colour; Console.Clear(); Console.WriteLine($"You created a {colour} square with side length: {side}, an area of {square.GetArea()} and a perimeter of {square.GetPerimeter()}"); Console.ReadKey(); } break; case "2": { Console.Clear(); Console.WriteLine("You are making a rectangle"); Console.WriteLine("What colour is it?"); string colour = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You are making a {colour} rectangle"); Console.WriteLine("How wide is it?"); double width = GetNum(); Console.Clear(); Console.WriteLine($"You are making a {colour} rectangle with width: {width}"); Console.WriteLine("How tall is it?"); double height = GetNum(); Rectangle rectangle = new Rectangle(width, height); rectangle.Colour = colour; Console.Clear(); Console.WriteLine($"You created a {colour} rectangle with width: {width}, height: {height}, an area of {rectangle.GetArea()} and a perimeter of {rectangle.GetPerimeter()}"); Console.ReadKey(); } break; case "3": { Console.Clear(); Console.WriteLine("You are making an equilateral triangle"); Console.WriteLine("What colour is it?"); string colour = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You are making a {colour} equilateral triangle"); Console.WriteLine("What is its side length?"); double side = GetNum(); Equilateral equilateralTriangle = new Equilateral(side); equilateralTriangle.Colour = colour; Console.Clear(); Console.WriteLine($"You created a {colour} equilateral triangle with side length: {side}, an area of {equilateralTriangle.GetArea()} and a perimeter of {equilateralTriangle.GetPerimeter()}"); Console.ReadKey(); } break; case "4": { Console.Clear(); Console.WriteLine("You are making a right angle triangle"); Console.WriteLine("What colour is it?"); string colour = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You are making a {colour} right angle triangle"); Console.WriteLine("How wide is it?"); double width = GetNum(); Console.Clear(); Console.WriteLine($"You are making a {colour} right angle triangle with base: {width}"); Console.WriteLine("How tall is it?"); double height = GetNum(); RightAngle rightAngleTriangle = new RightAngle(width, height); rightAngleTriangle.Colour = colour; rightAngleTriangle.SetHypotenuse(); Console.Clear(); Console.WriteLine($"You created a {colour} right angle triangle with base: {width}, height: {height}, hypotenuse: {rightAngleTriangle.Side3Length}, an area of {rightAngleTriangle.GetArea()} and a perimeter of {rightAngleTriangle.GetPerimeter()}"); Console.ReadKey(); } break; case "5": { Console.Clear(); Console.WriteLine("You are making a circle"); Console.WriteLine("What colour is it?"); string colour = Console.ReadLine(); Console.Clear(); Console.WriteLine($"You are making a {colour} circle"); Console.WriteLine("What is its radius?"); double radius = GetNum(); Circle circle = new Circle(); circle.Radius = radius; circle.Colour = colour; Console.Clear(); Console.WriteLine($"You created a {colour} circle with radius: {radius}, an area of {circle.GetArea()} and a perimeter of {circle.GetPerimeter()}"); Console.ReadKey(); } break; case "e": { running = false; } break; default: continue; } } }
static void Main(string[] args) { bool error = true; string answer = "0"; string colour; double side1 = 0; double side2 = 0; double radius = 0; RightAngle r; List <Square> squarelist = new List <Square>(); List <Rectangle> rectlist = new List <Rectangle>(); List <Equilateral> equillist = new List <Equilateral>(); List <RightAngle> rightlist = new List <RightAngle>(); List <Circle> circlelist = new List <Circle>(); while (answer != "6") { Console.Clear(); Console.WriteLine("Please Enter Which Shape You Would Like To Create!"); Console.WriteLine("1. Square"); Console.WriteLine("2. Rectangle"); Console.WriteLine("3. Equilateral Triangle"); Console.WriteLine("4. Right Angle Triangle"); Console.WriteLine("5. Cicle"); Console.WriteLine(); Console.WriteLine("6. Exit Program"); answer = Console.ReadLine(); if (answer != "1" && answer != "2" && answer != "3" && answer != "4" && answer != "5" && answer != "6") { Console.WriteLine("Not a Valid answer"); } else if (answer == "1") { Console.Clear(); Console.WriteLine("Please enter Colour: "); colour = Console.ReadLine(); Console.WriteLine("Please enter Square's Side Length: "); while (error == true) { try { side1 = int.Parse(Console.ReadLine()); if ((side1 % 1) > 0) { throw new NumberIsDecimalException(side1); } error = false; } catch (System.FormatException e) { Console.WriteLine("That is not a number, Please enter a Number: "); } catch (NumberIsDecimalException) { Console.WriteLine("Can not use Decimal Numbers, Please enter a Number:"); } } error = true; squarelist.Add(new Square(colour, side1)); Console.WriteLine("Shape Create Succesfully!"); Console.WriteLine("You have create a " + colour + " Square with a side length of " + side1 + "!"); } else if (answer == "2") { Console.Clear(); Console.WriteLine("Please enter Colour: "); colour = Console.ReadLine(); Console.WriteLine("Please enter Rectangle's First Side Length: "); while (error == true) { try { side1 = int.Parse(Console.ReadLine()); error = false; } catch (System.FormatException e) { Console.WriteLine("That is not a number, Please enter a Number: "); } } error = true; Console.WriteLine("Please enter Rectangle's Second Side Length: "); while (error == true) { try { side2 = int.Parse(Console.ReadLine()); error = false; } catch (System.FormatException e) { Console.WriteLine("That is not a number, Please enter a Number: "); } } error = true; rectlist.Add(new Rectangle(colour, side1, side2)); Console.WriteLine("Shape Create Succesfully!"); Console.WriteLine("You have create a " + colour + " Rectangle with a side length of " + side1 + " and " + side2 + "!"); } else if (answer == "3") { Console.Clear(); Console.WriteLine("Please enter Colour: "); colour = Console.ReadLine(); Console.WriteLine("Please enter Equilateral Triangle's Side Length: "); while (error == true) { try { side1 = int.Parse(Console.ReadLine()); error = false; } catch (System.FormatException e) { Console.WriteLine("That is not a number, Please enter a Number: "); } } error = true; equillist.Add(new Equilateral(colour, side1)); Console.WriteLine("Shape Create Succesfully!"); Console.WriteLine("You have create a " + colour + " Equilateral Triangle with a side length of " + side1 + "!"); } else if (answer == "4") { Console.Clear(); Console.WriteLine("Please enter Colour: "); colour = Console.ReadLine(); Console.WriteLine("Please enter Right Angle Triangle's First Side Length: "); while (error == true) { try { side1 = int.Parse(Console.ReadLine()); error = false; } catch (System.FormatException e) { Console.WriteLine("That is not a number, Please enter a Number: "); } } error = true; Console.WriteLine("Please enter Right Angle Triangle's Second Side Length: "); while (error == true) { try { side2 = int.Parse(Console.ReadLine()); error = false; } catch (System.FormatException e) { Console.WriteLine("That is not a number, Please enter a Number: "); } } error = true; r = new RightAngle(colour, side1, side2, 0); r.SetHypotenuse(); rightlist.Add(r); Console.WriteLine("Shape Create Succesfully!"); Console.WriteLine("You have create a " + colour + " Right Angle triangle with a side length of " + side1 + " and " + side2 + " and a Hypotenuse of " + Math.Round(r.Side3Length, 2) + "!"); } else if (answer == "5") { Console.Clear(); Console.WriteLine("Please enter Colour: "); colour = Console.ReadLine(); Console.WriteLine("Please enter Circle's Radius: "); while (error == true) { try { radius = int.Parse(Console.ReadLine()); error = false; } catch (System.FormatException e) { Console.WriteLine("That is not a number, Please enter a Number: "); } } error = true; circlelist.Add(new Circle(colour, radius)); Console.WriteLine("Shape Create Succesfully!"); Console.WriteLine("You have create a " + colour + " Circle with a radius of " + radius + "!"); } Console.ReadLine(); } Console.WriteLine("Closing Program..."); Console.ReadLine(); }