COMP 3522 Lab #9: Abstract Factory

$30.00 $24.00

Introduction Implement the abstract factory patern in C++ using the following canonical example. Set up your project Start by creating a new project: Clone‌‌your‌‌repo‌‌using‌‌github‌‌classroom:‌https://classroom.github.com/a/_RO7ETd5 Fill out your name and student number at the top of main.cpp Ensure you commit and push your work frequently. You will not earn full marks if you don’t Requirements Class…

Rate this product

You’ll get a: zip file solution

 

Categorys:

Description

Rate this product

Introduction

Implement the abstract factory patern in C++ using the following canonical example.

  • Set up your project

Start by creating a new project:

  1. Clone‌‌your‌‌repo‌‌using‌‌github‌‌classroom:https://classroom.github.com/a/_RO7ETd5

  1. Fill out your name and student number at the top of main.cpp

  1. Ensure you commit and push your work frequently. You will not earn full marks if you don’t

  • Requirements

    1. Class maze_factory is abstract. It builds mazes, rooms, walls, and doors between rooms. A maze_factory can be instantiated and passed to some other module to be used to create the parts of a maze.

      • maze_factory contains a virtual member function called make_maze that returns a new maze.

      • maze_factory contains a virtual member function called make_wall that returns a new wall.

      • maze_factory contains a virtual member function called make_room that returns a new room.

      • maze_factory contains a virtual member function called make_door that accepts references/pointers to two rooms and returns a new door that ‘connects’ them.

    1. Class maze_game is not abstract. It contains a method called create_maze that accepts a reference to a maze_factory and uses the maze_factory to build a maze. The create_maze method returns a pointer to the newly created maze.

    1. Classes, maze, room, wall, and door should be abstract. They will be part of the factory. They may have one or more virtual functions related to printing out their contents and describing their surroundings. The following is a suggested solution, your exact solution may difer slightly

        • Maze contains containers of pointers to rooms in the maze, and functions to add rooms to the maze.

        • Rooms contain pointers to 4 walls and a door

        • Door contains pointers to the 2 rooms its connected

        • Walls will simply print out the wall description

    1. Create concrete implementations of maze_factory, maze, room, wall, and door. Create two versions: an enchanted fairy land, and a futuristic dystopian maze.

    1. Ensure your implementation includes overridden output methods that describe the rooms.

  1. There should be no use of concrete types in any class “above” the boundary (refer to slides).

  1. You will need a driver.cpp that contains a main method. Inside the main method, instantiate a maze_game and pass to its create_maze function a reference to an enchanted fairy factory. Print the description of the created maze. Do the same thing with the futuristic maze.

  1. Remember that in order to earn full marks the low level implementation details must not appear outside of main or the implementing enchanted forest and futuristic classes.

  1. Comment your code.

  1. Things to note:

      • Don’t make new fles for every new class or else we’ll have over 20+ fles. Put related classes into one fle. eg: Maze, Fairy_Maze, Dystopian_Maze classes can be in one set of maze.hpp/cpp fles

      • Your output order doesn’t have to exactly match the sample output below

    1. YOU’RE DONE!

Good luck, and have fun!

  • Sample output

A pretty,

magical fairy maze

fairy Room 0: This room has fairies in it

fairy Room 1: This room has fairies in it

This door

has a fairy wing

for a handle.

This door

connects fairy Room 0 and fairy Room 1

This wall

has fairy wings on

it

This wall

has fairy wings on

it

This wall

has fairy wings on

it

This wall

has fairy wings on

it

This wall

has fairy wings on

it

This wall

has fairy wings on

it

This wall

has fairy wings on

it

This wall

has fairy wings on

it

An Orwellian dystopian maze

Dystopian

Room 0: This room is run

down and cracked

Dystopian

Room 1: This room is run

down and cracked

This door

has a pipe for a

handle.

This door

connects Dystopian

Room 0 and Dystopian Room 1

This wall

has surveillance

cameras

on it

This wall

has surveillance

cameras

on it

This wall

has surveillance

cameras

on it

This wall

has surveillance

cameras

on it

This wall

has surveillance

cameras

on it

This wall

has surveillance

cameras

on it

This wall

has surveillance

cameras

on it

This wall has surveillance cameras on it

  • Grading

This activity will be marked out of 10. For full marks this week, you must:

  1. (2 point) Commit and push to GitHub after each non-trivial change to your code

  1. (6 points) Successfully implement the requirements as described in this document

  1. (2 points) Write code that is consistently commented and formated correctly using good variable names, efcient design choices, atomic functions, constants instead of magic numbers, etc.

TIPS

  • You will be using a lot of dynamic memory to instantiate the maze, room, wall, and doors. Remember to delete them all. Where would be appropriate places to delete them?

  • Beware of forward declaration issues. room.hpp depends on door.hpp, and door.hpp depends on room.hpp. How do we properly solve this circular dependency with forward declaration?

Below is one possible solution class diagram for your solution:

Below is another possible solution that aggregates all the getDescription functions of the maze components into a generic MazeObject interface:

COMP 3522 Lab #9: Abstract Factory
$30.00 $24.00