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 3235474
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:30:39+00:00 2026-05-17T17:30:39+00:00

I’ve currently started on my semester project for my programming course- programming a fully

  • 0

I’ve currently started on my semester project for my programming course- programming a fully autonomous driving simulator. All cars are steered through AI and the map is printed in the console.

The first sheet wants us to create a couple of basic classes: FCCompact (The car), Scanner (AI), ID (terrain), and World (The map).

The Scanner is currently implemented as a “HAS-A” in my FCCompact class like so:

// FCCompact.h
class FCCompact
{
private:
    struct fImpl;
    fImpl *fImpl_;
/* ... */

// FCCompact.cpp
struct fImpl
{
    Scanner scanner_;
    /* ... */
};

The scanner function in question is

const ID& scanForID( int fovNumber,            // How far it can see
                     FCCompact::Direction dir, // Direction car is facing
                     const Location& loc);     // Location of car

So far so good. However, the entire map is located in a container vector< deque<ID> >(1) in the class World; I’m not sure how to access it.

The functions posted so far have been given to us by the teacher, so they should be able to be implemented with the parameters given. I just have no clue how to do that.

My first idea was to call World::getID(Location &), but it’s not static. Upon making it static, it can no longer access non-static members (duh, I forgot that). I have also made a static function that calls a non-static function; same problem (double duh).

Then I tossed the teacher’s guidelines and simply passed in the entire World object, but that didn’t really work either.

What can I do?

Please keep in mind that this is technically homework and that I do not want full, qualified answers that even gives me the entire implementation of what I want to do. I want to learn as much as possible from this project, so please just point me in the right direction.

(1): Weird choice for a container type? I figured if the world is printed on the console, quick access to each row with a vector would be beneficial, since there will be no insertion or deletion of queues and the access time is brilliant.

A deque, on the other hand, is handily for accessing ranges, which is favorable since I will frequently change adjacent columns (cars driving along the x- or y-axis). This choice did not come swiftly; I’m still torn between this, a list, or a simple vector again.

Classes

class World

class ID;
class World
{
    typedef std::pair<int, int> Location;

private:    
// vector<deque<ID> > map
// int mapHeight, mapWidth
// string mapName
    struct wImpl;
    wImpl *pimpl_;

public:
    World();
    ~World();

    void create(const std::string& name = "FC-City");

    int getHeight() const;
    int getWidth() const;

    ID getID(const Location& loc);

    friend std::ostream& operator<<(std::ostream& os, World& world)
    {
        return os;
    }

private:
    void loadMap(std::string name = "FC-City");

private:
    World(const World& other);
    World& operator=(const World& other);
};

class Scanner

class ID;
class Scanner
{
    typedef std::pair<int, int> Location;

public:
    Scanner();
    ~Scanner();

    const ID& scanForID( int fovNumber, 
                         FCCompact::Direction dir, 
                         const Location& loc);

private:
    Scanner(const Scanner& other);
    Scanner& operator==(const Scanner& other);
};

class FCCompact

class ID;
class FCCompact
{
    typedef std::pair<int, int> Location;

public:
    enum Direction
    {
        N, E, S, W, 
        NA = -1
    };

private:
// Scanner scanner
// Location loc
// Direction dir
// ID id
    struct    FCCImpl;
    FCCImpl  *pimpl_;

public:
    FCCompact( const ID& id,
               const Location& loc,
               const Direction& dir);

    FCCompact( const char ch,
               const Location& loc,
               const Direction& dir);

    const ID& getID()  const;
    Location  getLoc() const;
    Direction getDir() const;
    void      setDir( Direction& dir );

    void step();
    void hide();
    void show();
};

class ID

class ID
{
public:
    enum Trait
    {
        Traversable,
        NotTraversable,
        Mobile,
        Undef
    };

private:
    Trait trait_;
    char appearance_;

public:
    ID( char outputChar, Trait trait )
        : appearance_(outputChar), trait_(trait)
    { }

    ID( char outputChar )
        : appearance_(outputChar), trait_(Trait::Undef)
    { }

    char getToken()  const { return appearance_; }
    Trait getTrait() const { return trait_; }

    void setTrait(Trait trait) { trait_ = trait; }
};
  • 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-17T17:30:39+00:00Added an answer on May 17, 2026 at 5:30 pm

    Scanner should have a constructor that accepts a reference to a World; store a pointer to that argument so later when you need a world you have one.

    Don’t use a singleton, they’re stupid. You could use a global but there really isn’t a need here. A Scanner needs a World to operate on, ergo you construct it with a World to operate on:

    struct bar;
    
    struct foo
    {
        // foo cannot operate without a bar,
        // therefore it needs to be supplied with
        // one to be able to construct
        foo(const bar& pBar) :
        mBar(&pBar)
        {}
    
        void i_need_bar()
        {
            mBar->use_bar();
        }
    
        bar* mBar;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.