예제 #1
0
        static void Main(string[] args)
        {
            Square sqr = new Square();

            sqr.LengthofSides = 1.5;
            sqr.Print();
            //double area = sqr.GetArea();
            //double perimeter = sqr.GetPerimeter();
            //Console.WriteLine("Area is {0}, Perimeter is {1}", area, perimeter);

            Square sqr2 = new Square();

            sqr2.LengthofSides = 3.3;
            sqr2.Print();

            Rectangle Rec = new Rectangle();

            Rec.Length = 1.2;
            Rec.Width  = 8.2;
            Rec.Print();

            Circle Circ = new Circle();

            Circ.Radius = 5;
            Circ.Print();

            Circle Circ1 = new Circle();

            Circ1.Radius = 10;
            Circ1.Print();
        }
예제 #2
0
파일: Program.cs 프로젝트: Jwils21/Geometry
        static void Main(string[] args)
        {
            Square sqr = new Square();

            sqr.LengthOfSides = 1.5;
            double area      = sqr.GetArea();
            double perimeter = sqr.GetPerimeter();

            Console.WriteLine("Area: {0}, Perimeter: {1}.", area, perimeter);

            Square sqr2 = new Square();

            sqr2.LengthOfSides = 3.3;
            sqr2.Print();

            Rectangle Rect = new Rectangle();

            Rect.height = 1.2;
            Rect.width  = 8.2;
            Rect.Print();

            Circle Cir = new Circle();

            Cir.Radius = 1;
            Cir.Print();
        }
예제 #3
0
        static void Main(string[] args)
        {
            Circle    c1 = new Circle(4);
            Square    s1 = new Square(10);
            Rectangle r1 = new Rectangle(20, 4);

            c1.Print();
            s1.Print();
            r1.Print();
            Console.ReadLine();
        }
예제 #4
0
        static void Main(string[] args)
        {
            //creating a new variable of class Square
            Square sqr = new Square();

            //Obtain the length of one side

            /*
             * Console.WriteLine("What is the length of one side of the square? ");
             * sqr.LengthOfSides = double.Parse(Console.ReadLine());
             * Console.WriteLine();
             */

            //assign value of 1.5 to variable sqr.LengthofSides to be used to calculate area/perimeter
            sqr.LengthOfSides = 1.5;

            //using the methods to calculate area and perimter from the Square class through the sqr variable via sqr.LengthOfSides property
            double area      = sqr.GetArea();
            double perimeter = sqr.GetPerimeter();

            //Outputting the information after it has been calculated
            Console.WriteLine("One side of the square has a length of {0}", sqr.LengthOfSides);
            Console.WriteLine("The area of the square is {0}", area);
            Console.WriteLine("The perimeter of the square is {0}", perimeter);

            //doing the same as above but with sqr2 variable
            Square sqr2 = new Square();

            sqr2.LengthOfSides = 3.3;

            //calls the Square.Print function to work from class Square
            sqr2.Print();               //the print function replaces lines 25-32...it is from the Square class
            //end sqr2 variable code


            //Rectangle calculations
            Rectangle rect1 = new Rectangle();

            rect1.height = 1.2;
            rect1.width  = 8.2;
            rect1.Print();

            //circle calculations
            Circle circ1 = new Circle();

            circ1.r = 1;
            circ1.Print();

            Circle circ2 = new Circle();

            circ2.r = 2;
            circ2.Print();
        }
예제 #5
0
		static void Main(string[] args) {
			Square theSquare = new Square {
				LengthOfSides = 3.3
			};
			theSquare.Print();

			Rectangle theRectangle = new Rectangle {
				Height = 1.2,
				Width = 8.2
			};
			theRectangle.Print();

			Circle theCircle = new Circle {
				Radius = 3.1
			};
			theCircle.Print();

			Sphere theSphere = new Sphere {
				Radius = 3.2
			};
			theSphere.Print();

			Trapezoid theTrapezoid = new Trapezoid {
				FirstBase = 1.2,
				SecondBase = 2.3,
				Height = 3.4,
				FirstSide = 4.5,
				SecondSide = 5.6
			};
			theTrapezoid.Print();

			//for (var i = 0; i < 100; i++) {
			//	int[] array = { 1, 2, 3 };
			//	var rand = new Random();
			//	int picked = rand.Next(0, 2);
			//	int prize = rand.Next(0, 2);
			//	int show = rand.Next(0, 2);
			//	if (show == prize || show == picked) {
			//		show = rand.Next(0, 2);
			//	}
			//	if ()
			//	Console.WriteLine();
			}
예제 #6
0
        static void Main(string[] args)
        {
            Circle cir1 = new Circle();

            cir1.radius = 2.5;
            cir1.Print();

            Rectangle rect1 = new Rectangle();

            rect1.height = 1.2;
            rect1.width  = 8.2;
            rect1.Print();

            Square sqr = new Square();

            //we've defined a variable named sqr - it's type is the class Square. sqr is one instance of the square
            sqr.LengthOfSides = 1.5;
            //this is setting the value of LengthOfSides
            double sidelength = sqr.LengthOfSides;
            double area       = sqr.GetArea();
            //execute the GetArea method of the variable sqr
            double perimeter = sqr.GetPerimeter();

            //execute the method GetPerimeter on the variable sqr
            Console.WriteLine("The length of the side of the square is {2}.  Area is {0}.  Perimeter is {1}.", area, perimeter, sidelength);
            //this will print "Area is {the variable area}. Perimeter is {the variable perimeter}.  0 corresponds with area, 1 corresponds with perimeter.

            //Square sqr2 = new Square();
            //sqr2.LengthOfSides = 3.3;
            //Console.WriteLine("Area is {0}.  Perimeter is {1}.", sqr2.GetArea(), sqr2.GetPerimeter());
            //We don't have to create a variable that does these actions - we can just use the methods we built!


            //Better yet, we can just do the following, using what we did on lin 29 of our Square class:
            Square sqr2 = new Square();

            sqr2.LengthOfSides = 3.3;
            sqr2.Print();
        }