CSCI1120 Computing Using C++

SpringBoot+Vue+MySQL 高校学科竞赛平台 完整可运行版(源码+文档) 本项目基于SpringBoot+Vue+MySQL构建高校学科竞赛管理平台,覆盖学生、教师、领队教师、管理员四大角色,实现竞赛发布、报名、刷题、评分、公示等全流程闭环管理。系统架构清晰,技术主流,配套完整源码、数据库脚本、万字论文、开题报告、答辩PPT及部署文档,支持一键运行,适用于毕业设计、课程设计及院系二次开发,真正实现“开箱即用”。 阅读详情

CSCI1120 Introduction to Computing Using C++, Fall 2024/25

Assignment 6: Mathable Using OOP

Due: 23:59, Sat 7 Dec 2024                                                                                                          Full marks: 100

Introduction

The objective of this assignment is to practice the use of inheritance and polymorphism. Usage of strings, vectors and pointers is also included. You will implement the Mathable board game again but using an OOP approach this time.

In Assignment 4, we used static arrays and separate functions to implement the  board game with two variant settings, namely classical Mathable and Mathable Junior, which differ in board size, rack size and number of tokens. In this assignment, you are to reimplement the board game in an OOP style by developing several classes that model the game components.

For simplicity,

•   Only the Junior variant of the game is required. Its configuration is recapped in Table 1 below.

•   You may assume the board size, rack size, and total number of tokens are fixed (in Mathable.h).

•   No need to implement the “swap tokens” functionality – i.e., the option 'S' for the player’s action does not exist this time.

Table 1: Game configuration parameters of Mathable Junior

However, there are some new features to support:

•   The number of players can be varied between 2 and 4 at the program start.

•   Besides human players, we also implement computer players that make moves automatically.

•   The new game has to support two special types of squares in the original Mathable. Recall that

o Restriction  squares are  those   blue  squares   (in  Figure  1  GUI)  marked  with   an  addition, subtraction, multiplication or division sign. To occupy a square of this kind, the player must make an equation that corresponds to the sign of that square.

One of the original game rules reads “If a player places a token on a restriction square, he may, at that moment, take an extra token (from the bag) if he so wishes. This may not be postponed to a later turn.” To make it simple, we won’t implement this rule.

o Bonus squares are those  marked with “2x”  or “3x” . A  purple square marked 2x doubles the amount of point of the token on that square; an orange square marked 3x triples the number of points.

Game Board Representation

The gameboard is represented by a text-based grid as shown in Figure 1 below.

Figure 1: A GUI screenshot of the Mathable app versus our text-based game board representation

Program Specification

This section describes the starter code, class  hierarchy,  player actions, game-over conditions, the TODO classes that require your major work, and the program flow.

Starter Code

•    To help you get started, you are provided with all the required source files. There is a total of  17 files implementing this program – 8 classes (header and source files) plus the main client source.

•    Your task is to fill in your code for the missing  parts marked with TODO comments in only 8 of  these files. The last column of the Table 2 and 3 indicates whether the file has some TODO task(s) for you. Search the word “TODO:” to locate where you should fill in the missing code. Read the  instructions in the TODO comment to know what is expected to do. You may remove the TODO  comments after finishing the missing code.

Table 2: Header files for class definitions

File

Description

TODO

1

Square.h

Square interface

A base class modeling a square on board

N

2

BonusSquare.h

BonusSquare interface

A subclass modeling a bonus square

Y

3

RestrictionSquare.h

RestrictionSquare interface

A subclass modeling a restriction square

N

4

Player.h

Player interface

An abstract base class modeling a player

N

5

Bot.h

Bot interface

A subclass modeling a computer player

N

6

Man.h

Man interface

A subclass modeling a human player

N

7

Mathable.h

Mathable interface

A class modeling game board and bag

N

8

RandomNumberGenerator.h

RandomNumberGenerator interface

A custom random number generator

N

Note: The constants P = 4, N = 10, R = 5, and T = 60 are defined in Mathable.h, which correspond to maximum # players, board size, rack size, bag size (total # tokens) respectively.

Table 3: Source files for class implementations and client code

File

Description

Relation with other classes

TODO

9

Square.cpp

Square implementation

Base class

N

10

BonusSquare.cpp

BonusSquare implementation

Subclass of Square

Y

11

RestrictionSquare.cpp

RestrictionSquare implementation

Subclass of Square

Y

12

Player.cpp

Player implementation

Abstract base class

Y

13

Bot.cpp

Bot implementation

Subclass of Player

Y

14

Man.cpp

Man implementation

Subclass of Player

Y

15

Mathable.cpp

Mathable implementation

Player subclasses access board or bag via this object

Y

16

RandomNumberGenerator.cpp

RandomNumberGenerator implementation

Mathable’s setupBag() uses it for shuffling tokens

N

17

math-game.cpp

Mathable game client program

The main() function here

Y

•    We suggest the following development order.

o  The subclasses of Square: RestrictionSquare and BonusSquare;

o  Next is the Mathable class;

o  Then finish the base classes first: Player;

o  Followed by subclasses of Player: Bot and Man;

o  Finally, the game client program: math-game.cpp.

Class Hierarchy

Figure 2: The class inheritance hierarchies and relationship between classes

The Mathable class has a 2-D array of Square pointers, namely board[N][N], which implements the game board. BonusSquare and RestrictionSquare are subclasses of Square. They override the virtual function toString() to return more specific information like “3x” or “+” . The Player class  keeps a  pointer,  namely  mGame,  which  points  to  a  Mathable object. Then  methods  in the Player class or its subclasses can make moves, i.e., placing tokens on the game board, by calling the  methods  provided  by  Mathable.  Note  that  the  Player class  is  abstract  since  it  has  a  pure virtual  method  called  makeMove().  You  cannot  create  objects  of  this  class.  Man and  Bot are concrete  subclasses  of  the   Player class   modeling   a   human   player   and   a   computer   player respectively. They reuse the parent-level data such as score and rack as well as methods such as getScore() and rackSize(). They override their parent’s virtual makeMove() method to exhibit different behaviors in making moves – a human player enters a move via the keyboard whereas a computer player picks the move that obtains the highest points from all possible moves.

Besides the classes, we also define a type alias of int called Token in Square.hand we tend to use this alias for the type of variables storing a token. For example, a player’s rack is implemented as a vector storing the tokens, instead of writing vector rack, we would write vector rack, which looks more readable.

Human Player Actions:

There are 3 options of game actions that a human player (Man) can choose in each turn:

1. Play (P): play a move, i.e., select a token on the rack to place at a specified cell on the board.

2. End (E): end the current turn (if the player can’t see any more moves to make).

3. Terminate (T):  terminate  the  game   (prematurely).  Then   players’   current  total  scores   are compared to see who wins the game.

You may refer to Assignment 4 specification for their description.

Computer Player Actions:

A computer player (Bot) has no options for actions. It keeps playing all playable moves in a greedy manner, i.e., pick a combination of a token on its rack and a square on the board that can maximize the points gained by the current move, until there are no more possible moves. Then it passes the turn to the next player.

Game-over Conditions:

In this assignment, there are three game-over conditions:

(1)   There are no tokens left in the bag and one player has used up all tokens on his rack.

(2)    Every player has passed their turn to the next since they have no more possible moves.

•   Note: This situation can happen even if the bag is not empty (since the swap-tokens function is not supported in this assignment).

•   Hint: The possibleMoves() method provided by the Mathable class, to be discussed, can facilitate the detection of this situation.

(3)   A human player enters option T to terminate the game. (This allows us to end a game earlier as we wish, making program testing more flexible.)

Like Assignment 4, a draw game can happen if more than one players attain the same highest score.

小红书爬取实战指南 以上方案仅供技术学习参考,请确保遵守目标网站的服务条款和相关法律法规。 阅读详情

相关推荐

ABAP调用启信宝API

方法参数定义如下 源代码如下 method qxb_http_get. data:lv_url type string. "===============初始化=============================================== "获取http实例 cl_http_client=>create_by_destination( exporting destination = space importing

u012232542的博客 1315

CSCI1120 C++

container| |_| |CharacterUser Input𝑐 = 3𝑛!" finally.| |_| | |||_ _ _ _|| |_| | ||| |_| | ||| |_| | ||| |_| | |||_ _ _ _|

price6669的博客 846

JAVA + 海康威视SDK + FFmpeg+ SRS 实现海康威视摄像头二次开发

海康威视SDK接入方案摘要 本文介绍了使用海康威视官方SDK开发物联网平台摄像头接入功能的完整方案。系统采用Java后端集成HCNetSDK控制摄像头,通过FFmpeg将RTSP流转为RTMP推送到SRS流媒体服务器,前端基于HTTP-FLV协议实现视频播放。文章详细说明了开发准备工作,包括SDK下载、SRS部署、FFmpeg安装等关键步骤,并提供了数据库表设计和接口定义。核心部分展示了如何集成海康SDK,包括提取必要代码、加载DLL文件、配置打包插件等具体实现细节,最终形成了一套支持实时预览、回放和下载的

2401_83057947的博客 2268

CSCI1120 Introduction to Computing Using C++

container| |_| |CharacterUser Input𝑐 = 3𝑛!" finally.| |_| | |||_ _ _ _|| |_| | ||| |_| | ||| |_| | ||| |_| | |||_ _ _ _|

WX_codehelp的博客 858

共聚焦显微镜的光源、工作原理与选型

共聚焦显微镜作为科研与工业领域中重要的微观成像工具,凭借光源的精准适配性、光学切片技术的三维成像能力,以及对不同工业场景的定制化适配潜力,为半导体检测、工业部件分析、智能制造升级提供了关键技术支撑。深入理解其光源特性、工作原理与选型逻辑,能帮助工程师与技术人员精准匹配设备与生产需求,既保障微观检测的精度与效率,又为产业优化、技术创新筑牢微观观测的基础。

PhotonixBay的博客 1540

Pytorch入门实战(2)-使用BP神经网络实现MNIST手写数字识别

上一篇:Pytorch入门实战(1) - 实现线性回归 涉及知识点 Pytorch nn.Module的基本使用 Pytorch nn.Linear的基本用法 PytorchVision Transforms的基本使用 Pytorch中DataLoader的基本用法 Pytorch详解NLLLoss和CrossEntropyLoss 如何确定神经网络的层数和隐藏层神经元数量 本文内容 本文将会使用BP神经网络(就是最普通的神经网络)实现一个MNIST手写数据集的实现。话不多说,直接开始。 首先先导入需要的包

iioSnail的博客 6619

CSCI1120 Introduction to Computing Using C++ Fall 2024/25 4: MathableC/C++

File name:Mathable•Gameboard•Tokens(ortiles•Racks•Bag•Score padequationsa?b = cwhere?Amathequationiscompletedbyadding,oradjacentnumbersputtinga tokensquare,beittotherightorleft,belowor。

flechazt的博客 536

KEPServerEX 6 之 GE Ethernet 连接FANUC ROBOT机器人实战

GE Fanuc是GE公司控制系统部门的一部分,成立于1998年。其主要业务涵盖工业自动化、控制系统、PLC和组态软件等领域。其产品可用于包括自动化、过程自动化、国防、汽车制造、通讯、医疗和航空航天等各种工业领域2009 8月 GE和FANUC今天宣布两家公司已同意解除合资企业GE FANUC自动化公司。通过以上历史,GE Ethernet Driver 当下还支持对接FANUC ROBOT机器人 就不奇怪了。

-雲飛兄-博客 1796

InnoDB 内存结构总览:Change Buffer、AHI 与 Log Buffer

本文系统梳理InnoDB内存结构中的ChangeBuffer、Adaptive Hash Index(AHI)与LogBuffer。ChangeBuffer缓存二级索引页不在内存时的变更,减少随机IO,仅在页加载时合并;聚簇索引修改立即执行,因数据本身不可延后。AHI基于高频等值查询自动构建哈希索引,加速定位,仅支持等值操作。LogBuffer为redo log内存缓冲,配合磁盘日志实现崩溃恢复。三者均服务于性能优化,其中ChangeBuffer与AHI共享BufferPool空间,而LogBuffer独立

bksczm的博客 309

当SLAM遇上FPGA:打造一个会“硬件加速”的激光雷达SLAM系统

点云数据的运动畸变校正特征点提取与匹配、以及ICP迭代最近点配准。在传统方案中,我们通常用ARM核完成所有计算。但点云配准中的最近邻搜索(KD-Tree)需要大量分支判断,CPU处理起来效率很低;而ICP中的矩阵分解(SVD)虽然计算量大,但非常适合并行化。ZYNQ的特殊之处在于它把ARM(PS端)和FPGA(PL端)集成在同一颗芯片上。ARM擅长跑操作系统、处理复杂逻辑和调度,FPGA擅长做高吞吐量的并行计算。两者之间通过AXI总线高速互联,数据交换延迟只有几十个时钟周期。

QQ_778132974的博客 378

VTK:vtkAssembly用法实战

VTK:vtkAssembly用法实战程序输出程序完整源代码 程序输出 程序完整源代码 #include <vtkActor.h> #include <vtkAssembly.h> #include <vtkAxesActor.h> #include <vtkCubeSource.h> #include <vtkNamedColors.h> #include <vtkNew.h> #include <vtkOrientation

希望我的博客,能帮上你解决学习中工作中所遇到的问题 938

信创环境下PageOffice文档控件适配与实践

信创适配做到文档控件这一层,拼的已经不是"有没有国产版本",而是同一个功能在两类终端上是否真的等价。等价的标准很具体:同一次点击能得到同样的结果,同一份公文能得到同样的版式,同一个项目不需要维护两套代码。这背后是三件并不轻松的工作:服务端用一套接口同时支撑两类终端,客户端把两种系统与四种芯片的安装包分发清楚,文档内核层由产品侧跟着 WPS 的版本走。浏览器这一层的压力,则被收进了产品自己的窗口里——升级节奏由产品掌握,不再交给运气。

zi_wu_xian的专栏 336

AIGC时代的必备技能:提示词工程(Prompt Engineering)全面指南

本文主要介绍了AIGC时代的重要技能——提示词工程(Prompt Engineering)。文章首先定义了提示词的概念,强调其作为人类与AI沟通桥梁的重要性,并详细阐述了提示词的功能特性,包括输入、大模型处理和输出三个环节。接着,文章探讨了提示工程的重要性,如提高输出质量、节省资源和时间等。随后,文章深入分析了提示词的基本构成要素,包括指令、上下文、输入数据和输出指示符,并提出了提示词的五大基本原则:清晰性与具体性、提供充足的上下文、明确任务与目标、考虑受众和迭代思维。最后,文章介绍了提示词的七大常见技巧

weixin_43178406的博客 27万+

第三篇 第 6 课

前置:第三篇第 1 课(stdx 引入),第二篇第 1 课(std.regex)。环境:仓颉 SDK 1.2.0。本文所有代码与输出均逐行实测。

weixin_41618057的博客 557

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

【从零理解 Spring AI · 12】MCP 的两种角色:做客户端还是做服务端

上一篇讲了 MCP 的概念:标准协议、三大角色、M+N 替代 M×N。

nice_lcj520的博客 614

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

pcl2启动器下载(Minecraft PCL2 启动器 最新版 安装与使用说明)

摘要:PCL2(Plain Craft Launcher 2)是一款面向 Minecraft 的第三方启动器,支持正式版与快照版本管理、模组与整合包安装、Java 运行时自动匹配,绿色免安装、双击即可运行。适合在 Windows 上玩单机整合包、需要多版本共存或离线启动的用户使用

2611_96675819的博客 226

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

spring boot 4集成SQLLite,及其SQLLite的建库

spring boot 4集成SQLLite,及其SQLLite的建库

weixin_41463944的博客 231

Java 集合容器高频面试题全解:HashMap 树化阈值、1.7 死循环与 ConcurrentHashMap 演进(2026 招聘 JD 真题复盘)

HashMap 树化阈值 8 的泊松分布依据、退化阈值 6 的防抖设计、JDK 1.7 头插成环死循环的排查与修复、1.8 尾插后为何仍线程不安全、ConcurrentHashMap 放弃分段锁的原因与 ForwardingNode 协作扩容、computeIfAbsent 死锁陷阱、大集合找重复的场景题选型,附三层追问链自测。题目来源为 38 期公开招聘 JD 样本与字节、拼多多、建行、美团、快手公开面经。

蒙眼过河 427

spdlog 同步日志库使用详解

spdlog是一个轻量级 C++ 日志库,支持同步日志、异步日志、多线程日志、日志文件轮转和自定义日志格式。对于嵌入式 Linux 应用开发,我建议先使用。它可以帮我们完成:日志级别过滤。时间戳和线程 ID 输出。日志格式化。终端和文件输出。多线程安全写入。日志文件按大小或时间轮转。我们不需要自己实现互斥锁、文件写入、日志格式化和轮转等底层功能。

zengjiajun2006的博客 1124

JavaSE通关手册:数据类型与变量

代码无需额外处理,编译时编译器自动完成转换。

xys_678的博客 236

IDEA 简介:从零认识 IntelliJ IDEA

IDEA 全称,是由 JetBrains 公司开发的一款主流 Java 集成开发环境(IDE)。它集代码编辑、编译、调试、测试、版本控制、构建管理等功能于一体,被大量 Java 开发者视为日常开发的首选工具。所谓 IDE(Integrated Development Environment,集成开发环境),就是把写代码所需的各类工具整合到同一个界面中。相比只用文本编辑器加命令行编译,IDE 能显著减少重复操作,让开发者把精力集中在业务逻辑上。

ztI10的博客 184

Docker部署linkding:HTTPS与数据备份

部署私人书签库,除了让页面能够打开,还需要考虑几个实际问题:重建容器后数据是否保留、登录和保存是否正常、升级前怎样备份,以及出现 502 或 CSRF 错误时从哪里检查。本文使用 Docker Compose 部署 linkding,采用默认 SQLite 数据库,通过 Caddy 提供 HTTPS,并完成账户创建、数据持久化验证和备份。如果重建后账户或书签消失,应先检查是否换了项目目录、改了挂载路径,或者启动了另一套实例,不要急着重新初始化。遇到权限问题,应根据日志确认具体目录和运行用户,再调整权限。

tedcloud123的博客 193

C++20协程怎么运行?原理与三大核心组件深度剖析

C++20协程是轻量级的无栈状态机,通过co_await、co_yield、co_return实现挂起与恢复,由Promise、协程句柄和Awaitable三大组件协同工作。协程与线程互补,适用于高效管理大量并发I/O任务,显著降低上下文切换开销。其核心在于编译器生成的状态机机制,需配合库(如cppcoro)使用。掌握Promise控制逻辑、句柄生命周期管理及Awaitable语义,是构建高性能异步程序的基础。

Lucis__的博客 335

动态代理两大流派:JDK 代理与子类代理

业务类想加日志,最直白的写法是侵入式修改: 问题很明显:每个方法都要改一遍,改一个业务要动十处。代理模式的解法是:调用方不直接依赖 ,而是依赖一个代理对象。代理对象长得跟目标一模一样,调用它 → 代理先执行增强逻辑 → 再转调真实对象。 关键在于:代理对象的类型是哪来的?这就是"动态"二字的含义:代理类在运行时才诞生。两个角色: 承载增强逻辑, 负责生成代理类。 组装代理并调用: 输出: 业务代码 一行没动,增强逻辑全在 里。这就是 AOP 的味道。 内部四步: 第 2 步 内部:先查 (同一个接口

Android的专栏 661

c++ explicit关键字详解

explicit。

拒绝AI文,努力在AI时代写出感动人心的好文章 169

Java 项目实战:交友项目后台系统——网关统一鉴权与 B 端管理后台

本次改造通过引入SpringCloud Gateway实现网关统一鉴权与路由,新建mf-admin管理端复用C端域服务(Dubbo调用),实现管理员登录与用户管理四件查询。核心套路:网关白名单+双体系JWT(同工具不同payload)、管理端零直连业务库、分页形态区分(MySQL自动count/Mongo手动count)、浏览器端独立聚合。踩坑12条,附自检清单与后续改造方向,可复用于多角色后台系统。

Wang的专栏 63
上一篇: ESTR1002 Problem Solving by Programming
下一篇: ECO3121 Problem Set 3
wx____codinghelp
博客等级 码龄2年 771粉丝 115原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值