Thread: need help for a programming exercice

  1. #1
    Registered User
    Join Date
    Oct 2011

    need help for a programming exercice


    I am a first year programming student and I got problem solving an exercice I would be glad if you could help me.

    Write a program, Tut6_2.cs where robby walks around the perimeter of room 8
    , avoiding blue obstacles. In room 8, the obstacles are all one square wide (again), but of varied length.

    Your solution should use while loops to negotiate these obstacles

    namespace CE0721a {
      classtut6_2 {
        publicvoid run() {
    // make objects
          Robot robby = new Robot();
          Room room = new Room(8);
          Picture picture = new Picture(room, robby);
          while (true) {
            if (robby.ahead_is_colour(room, "white")) {
              if (robby.ahead_is_colour(room, "blue")) {
              if (robby.ahead_is_colour(room, "black")) {
    I attached a picture of the room 8.The problem I encounter is when the robot go up the obstacle I don t know how he can check at his right.

    Thank you in advance for your help
    best regards
    Attached Images Attached Images need help for a programming exercice-untitled-png 
    Last edited by Salem; 11-12-2011 at 02:14 AM. Reason: remove pointless tags

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Oregon, USA
    I'm guessing your location is just tracked in some X,Y coordinate...why not just check map[x + 1,y]? Need more information before we can help you with this. How's the map stored? How's the robot's location stored?
    If you understand what you're doing, you're not learning anything.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Just so you know, next time you should paste "text" and not "html" into the code tags.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Jun 2003
    Woah, for one, you have an infinite loop. Yes you might want it to repeat but you should always have an easy exit option other than the three finger salute.

    Next you should modify the routine to take into account the direction of movement just taken. Always think backwards.
    He who asks is a fool for five minutes, but he who does not ask remains a fool forever.

    The fool wonders, the wise man asks. - Benjamin Disraeli

    There are no foolish questions and no man becomes a fool until he has stopped asking questions. Charles Steinmetz

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Quote Originally Posted by thibault0613 View Post
    The problem I encounter is when the robot go up the obstacle I don t know how he can check at his right.
    Unless I am missing something in translation here, his "right" depends on what way he is facing.

    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help for my programming exercice
    By thibault0613 in forum C# Programming
    Replies: 5
    Last Post: 11-09-2011, 01:52 PM
  2. small programming job VCPP / Object Oriented Programming
    By calgonite in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 01-04-2006, 11:48 PM
  3. Total newb to programming here... Question about the many programming languages. Ty!
    By tsubotakid1 in forum A Brief History of
    Replies: 11
    Last Post: 10-05-2003, 10:32 AM