Write a console application that implements a Square shape.
Write a console application that implements a Square shape. Class Square should contain an instance property Side that has get and set accessors for private data. Provide two constructors: one that takes no arguments and another that takes a side length as a value. Write an application class that tests class Square's functionality*
Prashant JadhavPosted Jul 19, 2014, 9:06 AM
i think you want to create console with graphics which draw a box on console window i have
coded such program but i have written that logic in main function though you can create
class fro that code and use to create box.
Pradeep ShetPosted Jul 19, 2014, 5:15 AM
Find the below code-
class Square
{
public decimal Side{get;set;}
public Square(){}
public Square(decimal _side){ Side = _side; }
public decimal PrintArea()
{
return Side*Side;
}
}
class ExecutionClass
{
public static void Main(string[] str)
{
Square s = new Square(12.5);
//or
//Square s1 = new Square();
//s1.Side = 12.5;
Console.WriteLine(s.PrintArea());
Console.ReadKey();
}
}
Hope this answered your problem, mark it answered if it is so.