COM6471 a Wordle simulator

AI权益加码!Claude Code、Cursor等20+工具免费用! 购周边限时加赠Coding Plan Lite,畅享主流AI工具!学习进阶更高效! 阅读详情

这项任务的目的是编写一个Java程序来模拟Wordle。您的代码必须至少包括四个类:●WordleGame.java–这个类提供给您从Blackboard下载。您必须使用此代码,并且不应以任何方式对其进行修改。●BaseGame.java–提供了此类的大纲,供您从Blackboard下载。您将需要使用实例字段和方法来填充类●UserGuesses.java和ComputerGuesses.java-这些类应该扩展BaseGame.java,并且每个类都应该提供一个run()方法,该方法提供BaseGame.jva中抽象run()的具体实现您的程序应该使用javac WordleGame.java和java版本17进行编译,并且应该在户键入java WordleGame时运行。当它运行时,您的程序将生成以下对话框:

 Foundations of object-oriented programming 
Assignment 2023 – a Wordle simulator  
 
This is the assignment for COM6471 Foundations of Object Oriented Programming, 
The aim of this assignment is to test your ability to: 
●Write an object oriented program in Java that makes use of several different classes. 
●Write classes from a basic specification, which is vague in some details. 
Ensure that you read the entire assignment specification carefully before you begin. This is a challenging assignment, and you will need to allow some time to design your solution before you begin writing any code. 
Introduction 
This assignment requires you to build a Java program to simulate the popular game Wordle (see https://www.nytimes.com/games/wordle/index.html for details). In this game a 5-letter English word is chosen from a list, and the player must guess the word in six attempts or less. Following each guess, the player is told which characters in the guess are present in the chosen word, and which of these characters are in the right location. The player uses this information to deduce the chosen word. 
 
In this assignment, you will write a Java program to simulate Wordle that will run in one of two modes: 
1.Computer selects a word at random from a list that is stored in a text file, and the user has six attempts to guess the chosen word. 
2.User selects a word from a list that is stored in a text file, and the computer has six attempts to guess the chosen word. 
 
I have provided two Java classes, and your submission must use these classes, as well as others that are specified below. 
 
Unfair means 
We take the use of unfair means very seriously[]. This is an individual assignment. You must work on it alone and hand in your own code. You must not share code with other students, or submit work done by another student, or anyone else. 
You must not post this assignment to any website to seek assistance, and you must not use code downloaded from anywhere except the two classes I have made available on Blackboard. All submissions will be run through specialised software that detects similarity among Java programs, as well as similarity to online resources, and action will be taken in cases where unfair means are suspected. 
 
Task and requirements 
 
Overview 
The aim of this assignment is to write a Java program to simulate Wordle. Your code must include at least four classes: 
●WordleGame.java – This class is provided for you to download from Blackboard. You must use this code, and it should not be modified in any way. 
●BaseGame.java – An outline for this class is provided for you to download from Blackboard. You will need to populate the class with instance fields and methods. 
●UserGuesses.java and ComputerGuesses.java – These classes should extend BaseGame.java, and each should provide a run() method that provides a concrete implementation of the abstract run() method in BaseGame.java. 
Your program should compile with javac WordleGame.java, with java version 17 and should run when the user types java WordleGame. When it runs, your program will generate the following dialogue: 
 
A new game has been created 
Please select either (1) User guesses or (2) Computer guesses : 
 
User guesses game 
A game where the user guesses should then proceed as follows: 
 
Please select either (1) User guesses or (2) Computer guesses : 1 
Constructing a new game with user guesses 
The computer has selected a word, and you have 6 attempts to guess it. 
The computer will respond with: 
+ to denote a correct character in the right location. 
* to denote a correct character. 
X to denote an incorrect character. 
 
Attempt 1 of 6 
Available letters : abcdefghijklmnopqrstuvwxyz Please enter a word, 5 characters long : idler 
Checking -idler- is valid 
Word -idler- contains a-z only 
Word -idler- is valid 
Your guess : idler Response   : XX+*X 
 
Attempt 2 of 6 
Available letters : abc_efgh_jklmnopq_stuvwxyz 
Please enter a word, 5 characters long : uncle 
Checking -uncle- is valid 
Word -uncle- contains a-z only Word -uncle- is valid 
Your guess : uncle Response   : *XX*+ 
 
Attempt 3 of 6 
Available letters : ab efgh_jklm_opq_stuvwxyz  
Please enter a word, 5 characters long : 
 
And so on, until all 6 attempts have been used.
 
The first stage is for the computer to select a word, at random, from a list of 5-letter words that are read in from a text file. This text file must be stored in the same folder as the Java source code. You can use EasyReader to read the list. 
I have provided two text files for you to use. Each file has an integer on the first line, which gives the total number of words in the file. The file called FiveLetterWords.txt contains a list of 26 words, and is intended for you to use as you develop your code. Since the number of words is small, you will be able to check that your code is working correctly. 
 
The second file is called sgb-words.txt, and is a list of 5757 commonly used 5-letter words[ Available for download from https://www-cs-faculty.stanford.edu/~knuth/sgb.html  ]. Once you believe that your code is working correctly, your code should read in the words from this file instead. 
 
The final version your program that you submit should upload and store the words from sgb- words.txt, which must be located in the same folder as the Java code. Do not prefix the filename with a path such as C:\MyJava\Assignment. 
 
Each time the user enters a word, your program should check that it is a 5-letter word, and that it contains only alphabetic characters and hasn’t been tried before. If the word is too long, the user should try again: 
 
Please enter a word, 5 characters long : 24gerg 
Checking -24gerg- is valid 
Word -24gerg- is not the right length 
Word is not valid – try again 
Please enter a word, 5 characters long : 
 
In a similar way, if the word contains any incorrect characters, the user should try again: 
 
Please enter a word, 5 characters long : 12345 
Checking -12345- is valid 
Word -12345- contains incorrect characters, use a-z only 
Word is not valid - try again 
Please enter a word, 5 characters long : 
 
 
 
Similarly, if the word has been tried in previous attempt, your program should be able to tell in which attempt the word has been used (3/6 attempt below means the word never has been used in the third attempt) and ask the user should try a new word: 
 
Please enter a word, 5 characters long : never 
Checking -never- is valid 
Word -never- used in the 3/6 attempt, try another word 
Word is not valid - try again 
Please enter a word, 5 characters long : 
 
Following each attempt, your program should compare the selected word and the guessed word, and then produce a response that is composed of the three characters ‘+’, ‘*’, and ‘X’ indicating that the corresponding letters are in the correct location, present in the word, and not present in the word respectively. Your program should also be able to tell the repetition of letter(s) in the word. For example, if the correct answer is ‘never’, a response of ‘****X’ should be obtained for the guess ‘every’. This indicates there are two ‘e’s in the correct word. If the correct answer is ‘value’,  a response of ‘**XXX’ should be obtained for the guess ‘every’. This indicates only one ‘e’ in the correct word. A list of available letters should then be updated, replacing those letters that are not in the word with the underscore character ‘_’.  
 
At the end of the game, the user should be presented with a message that either congratulates the user for solving the puzzle, or explains that the maximum number of attempts has been exceeded and gives the correct answer: 
 
Attempt 6 of 6 
Available letters : ab_d_fghijk_m_opqrstuvwxyz Please enter a word, 5 characters long : uncle 
Checking -uncle- is valid 
Word -uncle- contains a-z only 
Word -uncle- is valid 
 
Your guess : uncle Response   : *XXXX 
You have not managed to guess the word this time. 
The correct answer was : fruit 
 
Computer guesses game 
If the user selects a game where the computer guesses, then the game should proceed as follows. 
 
Please select either (1) User guesses or (2) Computer guesses : 2   
Constructing a new game with Computer guesses 
Select a word by choosing a number between 0 and 25 : 6 
Attempt 1 of 6 
Guess is : kicks 
XXXXX 
 
Attempt 2 of 6 
Correct word : great, previous guess : kicks 
Total number of possible words is : 8 
Selecting a random word number : 5/8 
Guess is : tough 
*XX*X 
 
Attempt 3 of 6 
Correct word : great, previous guess : tough 
Total number of possible words is : 3 
Selecting a random word number : 3/3 
Guess is : never 
X*XX* 
 
Attempt 4 of 6 
Correct word : great, previous guess : never 
Total number of possible words is : 1 
Selecting a random word number : 1/1 
Guess is : great 
+++++ 
 
If the answer is guessed correctly within 6 attempts, the remaining attempts will be skipped. If the correct answer has not been reached, your program should continue until all 6 attempts have been used. 
 
First, the user should choose a word by selecting a number between zero and the number of words in the word list. In this example the word is chosen from the 26 words in the text file 
FiveLetterWords.txt, but your final submission should use the file sgb-words.txt so the word will be chosen from the 5757 words in this file. 
 
The computer should then guess a random word from the complete list for the first attempt only. For each subsequent attempt, the computer should construct a new list of words that do not contain characters that are identified by ‘X’ and not identified by ‘*’ or ‘+’, in the response to the previous guess. If you have followed the previous guideline to construct a new list of words that do not contain characters identified by ‘X’ without considering the ‘*’ and ‘+’ in the response to the previous guess, you will not lose any mark. You should decide on a suitable way to store each new list of words. A word will then be selected randomly from this list in the subsequent guess. 
 
General requirements and implementation notes 
●Your submission must conform to the specification below: 
oYour submission must use WordleGame.java, and you should add your own code to the template BaseGame.java. 
oYour submission must also include the required classes UserGuesses.java and 
ComputerGuesses.java 
oYour code must operate exactly as shown in the examples above. 
●Where there is no exact specification for the way the code should operate, you are free to choose a suitable approach. 
●You may ask questions about these requirements, but we cannot provide help with your 
assignment code, and will not check your code before submission. 
●Your code must compile from the command line, and should not be assigned to a package. 
●You can use any of the classes provided in the Java 17 API (https://docs.oracle.com/en/java/javase/17/docs/api/index.html)

●Although you are free to use more advanced Java features not covered in (e.g. the java Collections classes), it is not necessary to use them. 
●You must not use any other third party Java API or code library except for this package, and the classes provided. 
●Your code must read in a word list from the file sgb-words.txt, which must be stored in the same folder as the Java source code. 
You should write your code using a code editor. You should compile and run your code in the Command window prompt (Windows PC) or a terminal window (Mac or Linux), which is independent from the code editor.  Using an integrated development environment such as Eclipse or IntelliJ is not recommended because these tools are beyond the scope of this module. Using these tools will result in code that may not meet the general requirements listed above. 
 
Getting started 
As a first step you should write skeleton code for the UserGuesses and ComputerGuesses classes, which contains a constructor and a run() method, and uses System.out.println() to display where the focus of control is. 
The next step is to consider how each of the classes in the program relates to the other classes. This is best done on a sheet of paper. You should identify what each class needs to know, and what each class needs to do in order to deliver the requirements. 
You should also investigate if there are common behaviours and information that can be abstracted, and should consider if any additional classes are needed. You may decide that some variables can be defined as constants. Based on your analysis, you will be able to identify the instance fields and methods for each class. 
Code each class incrementally and use a test harness – either a separate test class with a main method, or a main method embedded in the class. 
Each time you make changes to the class, compile and test it. If it fails to compile, or runs incorrectly, then go back over your most recent changes and isolate the problem. 
 
Submission and deliverables 
Before you upload your code, check that it compiles on the command line using java. It is a good idea to check that it compiles and runs on one of the University computers. Check that your code is not part of a package. Do not submit archives (e.g. zip files) or .class files. 
 
Your code should then be submitted as a java files and uploaded to Blackboard using the upload tool 
Assessment 
Your code will be assessed for functionality and style. A mark of zero will be awarded for programs that do not compile; it is therefore important that you check that your code compiles on a University computer with Java 17 before you submit it, in case there are any issues with the configuration of your own computer. In particular, you should check that your code and comments do not contain any Chinese characters. 
Marks will be allocated as follows. 
Half of the marks (20/40) will be awarded for functionality and half (20/40) for design, testing, and style. There are many different ways to code the solution to this assignment. There is no single “correct” solution, and I fully expect a range of implementations to be submitted. However, some solutions are better than others because they are more concise, and more readable. 
Functionality will be assessed as follows: 
●Code compiles. If your code does not compile because it is incomplete or contains an error then you will be awarded a mark of zero. 
●The game is played correctly by the user : Computer selects random word from list stored in sgb-words.txt, user supplies up to 6 guesses, computer correctly identifies each character and returns the result (5 marks). 
●The game is played correctly by the computer : User selects random word from list stored in sgb-words.txt, computer generates an initial random guess, and then correctly generates a reduced list of words based on comparison between the random guess and the chosen word, computer then selects a word from this reduced list (10 marks). ● User input is validated correctly at each stage (5 marks).  
Design, testing and style will be assessed as follows: 
●Design. Each class in the design has clear responsibilities and collaborations with other classes, has an appropriate set of methods and instance fields, suitable access modifiers are used to preserve encapsulation, and abstraction is used to enable concise coding (5 marks). 
●Testing. Evidence of code used to test the behaviour of each class. This could be either a test harness for each class, or a separate test class (5 marks). 
●Style. Code is written with good style (10 marks). Code written in good style will have the following characteristics: 
oEach class will have a header comment, typically specifying the program name, the author, and the date. 
oOther comments will only be present where necessary to enable readability. 
oThe code is indented consistently throughout using four spaces and not tabs, so that the code in each method is easily identified. 
oVariables and methods have meaningful names (except for loop variables, which can be a single letter, e.g. for (int j = 0; j <= max; j++) ). Variables and methods should be in camelCase (e.g. gameType). 
oThere are sufficient lines of code to meet the requirements, and no extra, unreachable, or unnecessary code or comments. o See https://software.ac.uk/resources/guides/writing-readable-source-code for further details on how to write good quality readable code. 
wechat codinghelp

Unity零基础到进阶 | UGUI对象从创建到屏幕渲染完整流程 UGUI核心要点:脏标记驱动、分阶段重建(Layout→Graphic)、C#生成顶点数据,C++ Canvas做合批Batch,最后提交GPU 时间轴顺序:对象实例化 → Awake/OnEnable → 标记Dirty入队列 → Update执行游戏逻辑 → willRenderCanvases触发重建(Layout重建→裁剪→Graphic图形重建)→ C++ Canvas BuildBatch合批 → 提交GPU → 屏幕显示 阅读详情

相关推荐

C# AutoCAD 二次开发中的事务(Transaction)深度剖析:从基础原理到高级应用

本文深度剖析C# AutoCAD二次开发中的事务机制,强调其在保障原子性、线程安全与资源管理中的核心作用。重点阐述“黄金法则”——必须使用using语句管理事务,避免忘记提交或未结束事务的常见错误。深入讲解打开模式、对象升级降级、嵌套事务及事务组的应用,揭示性能陷阱与高级控制策略。强调事务仅在主线程中有效,杜绝后台线程操作,确保插件稳定高效。

ultramand的博客,重生之我在cad上二次开发猛猛敲C#代码~ 35

Statements without Semicolons

一条物理行 = 多条语句,完全合法;对比:Python 靠缩进和换行区分语句,C# 完全靠分号,这就是 “free-form 语言” 的特征。同样地,有些情况 —— 例如 using 声明 —— 虽然带有分号作为后缀,但它并不是一条语句。例如,代码清单 1.3 在一行里包含两条语句,两者结合,分别在两行中显示 Up 和 Down。由于换行并不分隔语句,你可以把多条语句写在同一行,C# 编译器会把这行解释为包含多条指令。实际上,代码块本身也被视为语句(代码块同样由语句组成),而且它们不需要以分号结尾。

龙山大佛爷的博客 164

C# .NET 周刊 |2026 年 8 月 4 期

本文介绍了用 C#、WinForm、WebView2、HTML 和 CSS 构建管理系统界面的方案。它强调用 WebView2 连接原生窗体和网页界面,实现数据传递、事件通知和样式切换,适合用户、权限、日志、报表等常见后台场景。方案思路清晰,实用性较强,但技术深度和原创细节一般,缺少实现代码和性能分析。

InCerry的博客 271

外贸独立站SEO优化全攻略:从0到1的完整指南

外贸独立站SEO是低成本获取精准海外流量的关键。本文系统梳理完整优化框架:从关键词研究(核心词与长尾词筛选)、站内优化(标题/URL/内链)、技术优化(HTTPS/速度/移动端/结构化数据),到内容营销、外链建设及本地化多语言策略,并涵盖数据监测与持续优化,助你建立系统化SEO知识体系。

2601_96764108的博客 276

Lua 基础语法(六)xLua Lua 调用 C# 交互

Lua通过cs.前缀访问C#类、对象与组件,使用冒号调用实例方法,点号调用静态成员。创建对象无需new,可直接调用类名;支持ref/out多返回值、params可变参数及委托事件订阅。注意重载函数因Lua统一为number类型,可能受桥接注册顺序影响。底层依赖虚拟栈与Gen桥接文件实现跨语言交互,需手动生成并注入代码。关键点包括命名空间前缀、:与.区分、事件注册移除、虚拟栈原理及热更新机制。

2301_80252792的博客 406

C# UdpClient 单播 三种通信版本

UDP单播:一对一精准通信,数据只能发送给指定唯一IP+端口的设备,点对点专属数据交互。手动自定义本机IP、本机绑定端口手动输入对方IP端口,可与任意UDP设备通信通用性最强,适配所有UDP点对点通信场景。

2401_84677775的博客 303

基于 C# / .NET 8 + Windows Forms + SQLite 的桌面银行业务演示系统——华夏示范银行管理系统

华夏示范银行管理系统是一款基于C#/.NET8+WindowsForms+SQLite的桌面端业务演示系统,采用分层架构设计,支持超级管理员、管理员与客户三类角色。系统集成登录认证、顶部导航、客户/产品管理、持仓价值计算、操作日志双写(SQLite+文本)、空闲自动登出及数据导出功能。通过“内容控件+按钮栏”组合模式实现页面动态扩展,支持自定义页配置与灵活功能开关,具备高可维护性与可拓展性,适用于银行业务流程教学与原型验证。

weixin_66547608的博客 159

Lua 基础语法(七)xLua 完整热更新 Demo

本文详解xLua Hotfix热更新技术,涵盖[Hotfix]标签作用与性能风险、AB包打包配置、UnityWebRequest异步下载及进度条实现、自定义AddLoader加载器注册、Lua热修复C#方法流程,并通过完整Demo演示从点击生成Cube到热更为红色Sphere的全过程。重点解析同名资源踩坑、Hotfix注入失效、重载函数调用异常等高频问题,对比xLua与下一代Huatuo(HybridCLR)热更新方案,强调其能力边界与选型建议,助力开发者掌握热更新核心技能并落地实战。

2301_80252792的博客 367

C# 图像使用AVX2指令集:使用OpenCvSharp实现字节图像解压缩速度和map_image算子速度提升

C# 图像使用AVX2指令集:使用OpenCvSharp实现字节图像解压缩速度和map_image算子速度提升

xianzuzhicai的博客 258

Lua 基础语法(四)C# 原生交互(LuaInterface)

LuaInterface是C#与Lua互调桥梁,含两个dll,已停维护但适合理解热更新原理。C#通过LuaEnv执行Lua字符串或文件,读取变量、调用函数、遍历表;Lua可用LuaNet加载C#程序集,访问实例(冒号)与静态成员(点号)。热更新核心:仅替换Lua脚本,C#无需重编译。

2301_80252792的博客 305

手写观察者模式:C#上位机状态通知的优雅解法

定义:定义对象间一种一对多的依赖关系,当一个对象状态改变时,所有依赖它的对象都会收到通知并自动更新。两个核心角色:角色别名职责Subject​主题 / 被观察者 / 发布者维护观察者列表,提供注册/注销,状态变化时通知Observer​观察者 / 订阅者定义接收通知的接口(Update 方法)注册(Attach)→ 变化 → 通知(Notify)。观察者模式的本质,是把"谁关心我变了"这个问题,从「编译期硬编码」变成「运行期动态注册」。简单场景用event(语言级、够用);

A_nanda的博客 459

数据结构-前缀树(Trie)

【代码】数据结构-前缀树(Trie)

SeanDragon的博客 214

学习C#开源报表组件Seal Report(26:Seal Report Designer界面布局-22)

学习Seal Report Designer软件左侧面板的Views节点中Model View控件的属性用途

gc_2299的博客 190

Unity · 性能优化:内存管理完全指南:从托管堆到跨桥开销

在 Unity 中,托管内存(C# 对象)与本机内存(引擎对象) 之间存在频繁的数据交换。这种跨越两个内存域的操作,被称为“跨桥”(Crossing the Bridge)。本机部分:场景中的 GameObject、Transform、Mesh、Texture 等,其核心数据存储在本机内存中。托管部分:我们在 C# 中持有的引用(如 Transform变量),实际上是一个托管包装器(Wrapper),它指向本机对象,但自身只占很少的内存。

gghhb12的博客 350

c#软件开发学习笔记--WPF(MVVM框架)

概念:区域(Region)是 Prism 中用来「动态容纳视图」的占位容器,替代传统<Frame>。你负责把视图放进去,展示的位置由区域决定。定义方式:在 XAML 中用附加属性prism:RegionManager.RegionName="区域名"标记某控件为区域(常用于):打开方式(两种)视图注入(固定投放)——启动时直接把视图放进来,之后不切换:_m = m;_m = m;

Z599817841的博客 342

Lua 基础语法(八) Unity Huatuo (HybridCLR)

HybridCLR是基于IL2CPP的Unity原生C#热更新框架,支持AOT编译,性能高、内存低,兼容泛型、反射等全语法,无需学习Lua。通过AssemblyDefine划分热更程序集,打包产出独立dll,运行时加载并反射调用。相比xLua需打标签、ILRuntime受限于iOS禁用JIT,HybridCLR可新增类与方法,支持完整热更新。需Unity 2019.4+,配置IL2CPP后端,热更dll需改后缀为.bytes并置于StreamingAssets,宿主加载后执行逻辑。

2301_80252792的博客 458

基于C#实现(WinForm)文件管理系统

本项目主要使用了两种主要的数据结构。首先是C# WinForm所内置的TreeView树结构,主要用来实现项目的目录树。另一种是自定义的森林结构,用来存放文件系统中的所有文件夹和文本文件,以及它们之间的对应关系。以下是自定义结点的部分定义。//左孩子//右兄弟//父结点//当前结点的信息左侧为文件系统目录结构树,以树型结构展示出了所有的文件夹以及文本文件。右侧是一些选项栏,可以进行格式化、新建文件夹等操作,同时可以看到程序目前的总块数和已用块数、

神仙别闹的自留地 179

微软技术周报 2026-08-31~09-07:GPT-6 Astra 登陆 Foundry、M365 全球认证故障复盘、C# 15 封闭层级

本期聚焦技术动态,不含财务信息。信息来源:Microsoft Learn、.NET News Daily、Azure Weekly(Issue 578)、Microsoft Security Blog、MSRC、Pureinfotech、9to5Windows、Neowin、BleepingComputer、InfoQ 中文、cnBeta、快科技、Microsoft 365 Message Center 等中英文媒体与官方渠道。

海盗Sharp的博客 437

Elasticsearch ES|QL:让全文本搜索无处不在

Elasticsearch 9.5引入MATCH与TO_TEXT组合技:TO_TEXT将任意字符串转为text类型,MATCH对运行时值进行真正的分词匹配,无需预建倒排索引。它支持未映射字段、keyword临时全文搜索、跨索引类型不一致等场景,替代LIKE/RLIKE的字符级匹配,实现大小写不敏感、词边界及词干处理,提升搜索语义准确性。

海兰 451
上一篇: COMPUTER NETWORKS
下一篇: CSCU9B3 Principles and Applications
thinkcsdn
博客等级 码龄3年 74粉丝 13原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值