Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CS I: Foundational C++ Projects

First-semester C++ coursework from Kent State: a text-based maze game and a dynamic collection class.

C++ License: MIT Kent State CI

Overview

This repo collects two labs I wrote during Computer Science I (CS13001) at Kent State in Fall 2022, my first semester of C++. The work is intro level. It covers classes, dynamic memory, the copy-control members, and console I/O. I kept the code as I submitted it and added documentation around it so the projects are easy to read and build.

Projects

Maze Game

A mouse starts in the top-left room of a 4x4 grid and has to reach the cheese room in the far corner. The program scatters internal walls at random, then asks me which way to move. If a wall sits between the current room and the room I picked, the move is refused. Rooms are named by a letter for the row and a number for the column, so the start room prints as a1 and the cheese room as d4.

do you want to see walls? (y/n)
y
a2|b2 c1|c2 a3|a4 b1|c1 d2|d3 a1|b1 c3|d3 b4|c4
the current room is: a1
What is your next move? u, d, l, r, or q: r
the current room is: a2
What is your next move? u, d, l, r, or q: d
There is a wall
What is your next move? u, d, l, r, or q: r
the current room is: a3
...
Game Over!

Controls:

Key Move
u up (toward row a)
d down (toward row d)
l left (toward column 1)
r right (toward column 4)
q quit

See the Maze Game wiki page for how generation, movement, and the win check work.

Collection Class

A container that holds a set of unique doubles in a dynamically allocated array. Adding a number grows the array by one and skips duplicates. Removing a number shrinks the array and shifts the tail down. The class carries its own copy constructor, assignment operator, and destructor so copies stay independent. A small driver reads a/r/q commands and prints the running total.

See the Collection Class wiki page for the class layout and memory notes.

Tech Stack

  • C++11
  • C++ standard library: <iostream>, <cstdlib>, <ctime>
  • Console (terminal) input and output

Architecture

flowchart TD
    subgraph Maze[Maze Game]
        G[game.cpp main] --> M[Maze]
        M --> RP[RoomPair]
        RP --> R[Room]
    end
    subgraph Coll[Collection]
        U[userInput.cpp main] --> C[Collection]
        C --> A[(double array)]
    end
Loading

Getting Started

You need a C++ compiler that supports C++11. The commands below use g++.

Build the maze game:

g++ -std=c++11 maze/*.cpp -o maze
./maze

Build the collection driver:

g++ -std=c++11 collection/*.cpp -o collection
./collection

To play the maze, answer the walls prompt (y prints the wall list, handy for testing), then type a direction key each turn. Reach d4 and the game ends.

Project Structure

cs1-projects/
├── maze/
│   ├── game.cpp        # main game loop
│   ├── maze.cpp        # Room, RoomPair, Maze definitions
│   ├── maze.hpp        # class declarations
│   └── Lab9_Game.vcxproj
├── collection/
│   ├── collection.cpp  # Collection member definitions
│   ├── collection.hpp  # Collection declaration
│   ├── userInput.cpp   # driver / main
│   └── Lab11_CollectionClasses.vcxproj
├── wiki/
├── .github/workflows/ci.yml
├── LICENSE
└── README.md

The .vcxproj files are Visual Studio project files left from when I built the labs. The g++ commands above do not need them.

Roadmap

These are honest follow-ups, not promises. The code stands as submitted.

  • Fix the functions that fall off the end without returning a value (goodDirection, pickAdjacent, checkMaze).
  • Seed the random generator once instead of calling srand(time(nullptr)) inside each pick.
  • Fix the dangling-else brace in Maze::move so the wall message and return false are not both unguarded.
  • Use delete[] instead of delete for the arrays in Collection.
  • Render the maze as a grid rather than a list of wall coordinates.

Author & Acknowledgments

Brandon Robare. This is academic coursework for Kent State University, Computer Science I (CS13001), Fall 2022. The header and class interfaces were provided by the course instructor, Mikhail Nesterenko. I wrote the member function definitions and the game and driver programs.

License

MIT. See LICENSE and the license note in the wiki.

About

Foundational C++ projects from Kent State Computer Science I: an ASCII maze game with random wall generation and a dynamic collection class with full value semantics.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages