All Projects

Raiinet

Design
Game Dev
XWindow Graphics

Game that applies Object-Oriented Programming concepts, CS246 Group Project

RAIInet is a multiplayer game played on a 8x8 board between two players who each control eight pieces called links. We constructed the overall structure around this basic 8x8 grid by adding elements, the displays, and abilities, where elements are the pieces in the game - Server port, Firewall, Data, and Virus. Then, these features are linked together with the Game class. The main classes that drive the game are Game and Player, which respectively owns the board and the elements.

Object-Oriented Principles and Design Patterns


For the design patterns, we used MVC(Model-View-Controller) pattern, Observer pattern, and Iterator pattern.
Encapsulation: We enforce invariants by using encapsulation. Clients(players) would access and interact with the game through the commands in main.cc. Otherwise, the specific implementations of the game logistics as well as the information stored in Game, Board, and Player would be inaccessible to the clients.
Abstraction: Observer, Element, and Link are abstract classes that assists with encapsulation of unnecessary details stored in the classes, and they are generally inaccessible by neither Game or Player. By using abstraction, modular design would be supported, which makes the code more organised and manageable.
Inheritance: For Observer and Element, we used inheritance so that subclasses Serverport, Firewall and Link could access its superclass Element’s fields. Then, classes Data and Virus also inherit from Link. By using inheritance, we improve the reusability of our code and increase convenience in case we want to add extra classes that use a common interface.
Polymorphism: Following from inheritance and abstraction, each subclass like Serverport, Firewall, and Link would have different underlying data fields but the same method, except the method would vary a bit for each class based on polymorphism. This is overriding. Other than that, we used operator overloading for Board and TextDisplay.