Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6068211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:41:28+00:00 2026-05-23T09:41:28+00:00

class Bug { // An ant is represented by the coordinates of its location,

  • 0
class Bug {

// An ant is represented by the coordinates of its location,
// and the direction it is facing.
Integer x;
Integer y;
Dir dir;

enum Dir { E,W,N,S }
}

Bug(Integer x, Integer y, Dir dir) {
    this.x = x;
    this.y = y;
    this.dir = dir;
}}

class BugWorld {


Integer theBreadth, theHeight;
Board board;
Bug bug;

BugWorld(Integer breadth, Integer height) {
    board = new board(breadth, height);
    bug = new Bug(breadth/2, height/2, Ant.Direction.Y);
    theBreadth = breadth;
    theHeight = height;
}

I already have the following:

Status status(Integer x, Integer y) {
    return board[x][y];
}


void update(Integer x, Integer y) {
    board[x][y].next();
}

This part below is where I’m having some trouble:

/* Take the world of the bug to the next step. */
void step() {
    // 1) Get the state at the present bug position.
          //I've done the following (next line) so far.
           Bug status(Integer x, Integer y); ...?

    // 2) Change the 'status' at that position.
             .............?
}

It’s just combining these that I’m having trouble with.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:41:29+00:00Added an answer on May 23, 2026 at 9:41 am

    It’s hard to understand what you’re trying to do, but I think here’s what you want

    void step(){
    
         //get the location of the bug 
         int x = bug.x;
         int y = bug.y;
    
         //gets the status of the location of the bug
         Status s = status(x,y);
    
         //move the bug, or do something based on the status of the place
    
         //update the status of the location the bug was originally on
         update(x,y)
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just stumbled across this bug in some legacy code: class MyAPIHandler { private:
Can someone recommend a workaround for this ironpython bug? I have a class contained
Is this bug in Parallel.For? public class DataPoint { public int Game { get;
I'm not sure if this is a bug in the DefaultModelBinder class or what.
My app has an occasional bug in it. Flurry shows me this: class java.lang.RuntimeException
I published this class at different places but now found a bug. It has
I am encountering the following bug. I have a class Foo . Instances of
I'm writing a simple nD-vector class, but am encountering a strange bug. I've stripped
This bug may be lurking since the beginning of ruby-mode , but I noticed
I define a simple Bug Class: using System; namespace BugNS.Entities { class Bug {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.