Add Bomb Room Maze Factory mode modification has been compiled

Source: Internet
Author: User

#include <iostream>using namespacestd;enumDirection {n, East, South, West,};classMapSite { Public:    Virtual voidEnter () =0;};class: PublicMapSite { Public: (intRoomno): _roomnumber (Roomno) {}; MapSite*getside (Direction)Const; Virtual voidSetside (Direction Direction, MapSite *) {cout<<"Set the"<<_roomnumber<<" the"<<direction<<"side."<<Endl;    }; intGetroomno () {return_roomnumber;    }; Virtual voidEnter () {cout<<"Enter the hostel."<<Endl; };Private: MapSite*_sides[4]; int_roomnumber;};classBombroom: PublicThe hostel { Public: Bombroom (intnum): Guest (num) {_roomnum=num;    }; Virtual voidSetside (Direction Direction, MapSite *) {cout<<"Set the"<<_roomnum<<"Bomb"<<direction<<"side."<<Endl; };Private:    int_roomnum;};classWall: PublicMapSite { Public: Wall () {}; Virtual voidEnter () {cout<<"Enter the wall."<<Endl; };};classDoor: PublicMapSite { Public: Door (* =0, room* =0) {}; Virtual voidEnter () {cout<<"Enter the door."<<Endl;    }; the*othersidefrom (room*) {};Private: the*_room1; the*_room2; BOOL_isopen;};classMaze { Public: Maze () {}; voidAddroom (room*Guest) {cout<<"Add the"<< Room->getroomno () <<"."<<Endl;    }; the* ROOMNO (int)Const{};};classMazefactory { Public: Mazefactory () {}; Virtualmaze* Makemaze ()Const {        return NewMaze;    }; Virtualwall* Makewall ()Const {        return NewWall;    }; Virtualroom* Makeroom (intNConst {        return New(n);    }; Virtualdoor* Makedoor (room* R1, room* R2)Const {        return NewDoor (R1, r2); };};classBombmazefactory: PublicMazefactory { Public:    Virtualroom* Makeroom (intNConst {        return Newbombroom (n); };};classMazegame { Public: Maze* Createmaze (Mazefactory &Factory) {Maze* Amaze =Factory.        Makemaze (); the* R1 = factory. Makeroom (1); the* R2 = factory. Makeroom (2); Door* Thedoor =Factory.        Makedoor (R1, r2); Amaze-Addroom (R1); Amaze-Addroom (R2); R1-Setside (North, Factory.        Makewall ()); R1-setside (East, Thedoor); R1-Setside (South, Factory.        Makewall ()); R1-Setside (West, factory.        Makewall ()); R2-Setside (North, Factory.        Makewall ()); R2-Setside (East, factory.        Makewall ()); R2-Setside (South, Factory.        Makewall ()); R2-setside (West, Thedoor); returnAmaze; };};intMain () {Mazegame mygame; //Mazefactory Factory;Bombmazefactory Factory; Mygame.    Createmaze (Factory); System ("Pause"); return 0;}
View Code

Add Bomb Room Maze Factory mode modification has been compiled

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.