I am working on a project:
For this project, you’ll create a form that lets the user move a simple
robot a given direction and distance. You’ll also create a class that
performs the robot movements.

The robot is displayed as an arrow that points in the currently selected
direction.

The user can move the robot 1 or 10 units in the selected direction by
clicking the Go 1 or Go 10 button.

The robot’s current X, Y position is displayed in a label at the top of the
form.
Specifications
Create a class named Robot that has a method that causes the robot to
move, a public field that contains the current direction, and a property that
returns the robot’s current position as a Point structure. When the robot is
instantiated, the position should be set to 0, 0 (the center) and the direction
should be set to North.


Limit the range of the robot to 100 units in any direction. If the user
attempts to move the robot beyond this range, the Robot class should raise
an event. The application should respond to this event by displaying an
appropriate message.

so far I am working on the Class portion and I have:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RobotCS
{
    class Robot
    {
         public enum Direction
        {
            North, West, South, East
        }
        public Robot() // Default constructor
        {
            location = new Point(); // Sets location.X=0 and location.Y=0          
            direction = Direction.North;
        }
        public Direction direction { get; set; }

        public Point location { get; set; }

        public void Move(int unitToMove)        
        {
            Point P = new Point();
            switch (direction)
            {
                case Direction.North:
                    P.X = location.X;
                    P.Y = location.Y - unitToMove;
                    break;
                case Direction.West:
                    P.X = location.X - unitToMove;
                    P.Y = location.Y;
                    break;
                case Direction.South:
                    P.X = location.X;
                    P.Y = location.Y + unitToMove;
                    break;
                case Direction.East:
                    P.X = location.X + unitToMove;
                    P.Y = location.Y;
                    break;
                default:
                    break;
            }
            location = P;
        } 
    }
  }

but Point keeps coming up as an error "namespace point cannot be found" any and all help would be great!
-Crima

Recommended Answers

All 2 Replies

forgot using System.Drawing; :)

On what line does this error occur?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.