2
Reply

Classes and private methods....

Prime b

Prime b

Feb 1 2012 9:35 PM
2k
The problem:
Create a class named Square that contains fi elds for area and
the length of a side and whose constructor requires a parameter
for the length of one side of a Square. Th e constructor
assigns its parameter to the length of the Square's side fi eld
and calls a private method that computes the area fi eld. Also
include read-only properties to get a Square's side and area.
Create a class named DemoSquares that instantiates an array
of ten Square objects with sides that have values of 1 through
10. Display the values for each Square

This is what I have done:
    class Square
    {
        public double area;
        public double sideLength;

        Square(double length)
        {
           sideLength = length;

           return;
        }
        public double SquareSide
        {
            get { return sideLength; }
           
        }
        public double SquareArea
        {
            get { return area; }
           
        }
        private static void AreaMethod()
        {
        
        }

I cant figure out how to call private method... How can they ask questions when they never taught how to solve!

Answers (2)