Design and implement a class called circlelocation to keep t

Design and implement a class called circle_location to keep track of the position of a single point that travels around a circle. An object of this class records the position of the point as an angle, measured in a clockwise direction from the top of the circle. Include these public member functions:
• A default constructor to place the point at the top of the circle.
• Another constructor to place the point at a specified position.
• A function to move the point a specified number of degrees around the circle. Use a positive argument to move clockwise, and a negative argument to move counterclockwise.
• A function to return the current position of the point, in degrees, measured clockwise from the top of the circle. Your solution should include a separate header file, implementation file,
and an example of a main program using the new class.

Solution

This program is created in C# language on Microsoft .NET platform.

Created in Visual Studio provided by Microsoft.

Detailed classes with description in comments marked as double slash \"//\"

----------------------------------------

public class circle_location

    {

        // location variable

        public static decimal CurrentLocationDegrees { get; set; }

        // default constructor

        public circle_location()

        {

            // initially set location to zero

            CurrentLocationDegrees = 0;

        }

        // parameterised constructor

        public circle_location(decimal Degrees)

        {

            // set location to value from input parameter

            CurrentLocationDegrees = Degrees;

        }

        public void MovePointer(decimal DegreesToMoveBy)

        {

            CurrentLocationDegrees = CurrentLocationDegrees + DegreesToMoveBy;

        }

        public decimal GetCurrentLocation()

        {

            return CurrentLocationDegrees;

        }

    }

2. Class Program: Actual use of above mentioned class is demonstrated here

class Program
{
static void Main(string[] args)
{
decimal moveByDegrees = 0;
// initialize
circle_location objCircleLocation = new circle_location();
Console.WriteLine(\"Initialize. Set Point to zero.\");
// get current location
Console.WriteLine(string.Format(\"Current location: {0} Degrees\ \" , objCircleLocation.GetCurrentLocation()));

// move point clockwise
moveByDegrees = Convert.ToDecimal(10.5);
Console.WriteLine(\"Move Point Clockwise by \" + moveByDegrees);
objCircleLocation.MovePointer(moveByDegrees);

// get current location
Console.WriteLine(string.Format(\"Current location: {0} Degrees\ \", objCircleLocation.GetCurrentLocation()));

// move point ani-clockwise
moveByDegrees = Convert.ToDecimal(-4);
Console.WriteLine(\"Move Point Anti Clockwise by \" + moveByDegrees);
objCircleLocation.MovePointer(moveByDegrees);

// get current location
Console.WriteLine(string.Format(\"Current location: {0} Degrees\ \", objCircleLocation.GetCurrentLocation()));
}
}

Design and implement a class called circle_location to keep track of the position of a single point that travels around a circle. An object of this class record
Design and implement a class called circle_location to keep track of the position of a single point that travels around a circle. An object of this class record

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site