School of Computer Science, University of Leeds
Portfolio Assignment 1
Your portfolio is a collection of work completed over the course which evidences how you have
met the learning outcomes of the module. Portfolio assignments are assessed, and you will
receive both formative (supportive feedback to help you improve) and summative (final, marked
feedback with a grade) feedback on your portfolio assignments during lab sessions and through
Gradescope.
You must achieve a minimum of a pass (4) in each portfolio assignment to progress to level 3.
Academic Integrity and Generative AI
By submitting your portfolio assignment, you are acknowledging that all work in the task was
done by you independently. If you are found to have plagiarised, colluded, or otherwise
breached the University’s expectation of academic integrity you will be subject to the
University's academic integrity processes.
You can find out more about academic integrity at Skills@Library through Minerva.
All tasks are rated AMBER for use of AI: AI tools can be used in an assistive role.
Within this assignment you may use Generative AI to:
- help you start to understand more complex ideas by providing accessible summaries.
- test your knowledge against a piece of content.
- help identify and correct spelling mistakes and grammatical errors in your work.
- provide feedback and advice on your overall coding style.
You must not use Gen AI to:
- produce written content (code, comments or any other content) which you then submit
as your work, regardless of whether you make changes to it.
- rewrite or make changes to any of your work.
Learning Outcomes:
- Use version control systems effectively
- Develop test suites
- Use a unit testing framework to do thorough testing
This work should be submitted by 17:00 on Friday 24th October.
Portfolio Assignment 1: Wordle
Introduction
In this assignment, you will create a simplified version of the word guessing game Wordle.
Your program will
• Read a large list of 5-letter words from a file and store them
• Pick a random word from this list
• Repeatedly prompt the user to guess the chosen word
• Give feedback on which letters have been guessed correctly
IMPORTANT: You must do this work in a clone of your GitHub repository, in the directory
portfolio/wordle.
This has been set up for you as a Gradle project. You will use Gradle to run tests, run the
program and perform checks on code quality.
Requirements
In the file Wordle.kt, implement the six Kotlin functions described below.
1. isValid(word: String): Boolean
Returns true if the given word is valid in Wordle (i.e., if it consists of exactly 5 letters)
2. readWordList(filename: String): MutableList<String>
Reads Wordle target words from the specified file, returning them as a list of strings.
(See the Baeldung article on reading from files in Kotlin for help with this.)
3. pickRandomWord(words: MutableList<String>): String
Chooses a random word from the given list, removes that word from the list, then
returns it.
4. obtainGuess(attempt: Int): String
Prints a prompt using the given attempt number (e.g. "Attempt 1: "), then reads a word
from stdin. The word should be returned if valid, otherwise the user should be prompted
to try again.
5. evaluateGuess(guess: String, target: String): List<Int>
Compares a guess with the target word. Returns a list containing 5 integers,
representing the result of comparison at each letter position. 0 indicates no match, 1
indicates a match.
6. displayGuess(guess: String, matches: List<Int>)
Displays the letters of a guess that match target word, or a ‘?’ character where there is
no match.
Unit Tests
Write unit tests for four of the functions listed in the previous section. You do not need to write
tests for obtainGuess() or displayGuess().
Your tests should be written using the Kotest framework, in the file WordleTest.kt. You should
be familiar with the required syntax from Worksheet Tasks 6.4.1 and 6.4.2.
TIP: write the tests for a function as you are implementing that function. Don’t move on to the
next function until all tests pass for the one you are working on.
Main Program
Use the six functions mentioned previously to create a program that plays a simplified version
of Wordle. The program should be implemented in the file Main.kt.
• Your program should not use command line arguments
• It should read its list of words from the file data/words.txt
• It should allow the player to make up to 10 attempts at guessing the chosen word
• It should display appropriate error messages if the user guesses successfully or they run out
of guesses
Running Your Code
Run all your tests with this command:
./gradlew test
Run the main program with
./gradlew run
(Note: we assume the use of Linux or macOS here. If you are using Windows, you will need to
adjust these commands accordingly.)
Checking Code Quality
Code quality can be checked using two different tools: ktlint and detekt.
These tools have overlapping capabilities, so it is worth running both to check that you are
writing properly styled, good-quality code.
To run only the ktlint checks, do
./gradlew ktlintCheck
To run only the detekt checks, do
./gradlew detekt
To run both checking tools and run the tests, do
./gradlew check
Both checking tools output their findings to the console. Both also generate reports in
subdirectories of build/reports.
Enhancements
These are not required to pass the assignment, but will improve your final mark.
First, modify evaluateGuess() to apply the full rules of Wordle. It should now return
• 0 for guess letters that are not present in the target word
• 1 for letters that are in the target word but at a different position
• 2 for letters that have been guessed correctly
You will also need to limit the number of allowed guesses to 6.
Second, add colour to the terminal output. Your main program should now display all the letters
of the current guess, using yellow to indicate a letter that is in the wrong place and green to
indicate a letter that has been correctly.
Don’t forget to update your tests for evaluateGuess() if you make these changes!
Questions
If anything is unclear, please ask the staff in your timetabled classroom session about it, or post
your question to the Assessment Questions channel set up for COMP2850 in Microsoft Teams.
Deliverables
Your work must be committed and pushed to GitHub by the stated deadline. In addition, you
MUST submit these three files to the Gradescope submission point in Minerva:
Main.kt
Wordle.kt
WordleTest.kt
Submission of these files is required to get a pass on this assignment.
Marking Criteria
We will assess your work and offer verbal feedback in the timetabled classroom sessions,
so please make sure you attend them!
In addition to giving verbal feedback we will assign your work a numerical mark, on a 0 – 10
scale. A mark of 4 or higher is a pass.
Marks higher than 4 have no influence on your final module grade, but should, along with the
feedback, provide you with a good indication of the overall quality of the work you submitted.
You may resubmit failing work up until the hard deadline near the end of term (5th December),
but we cannot guarantee that resubmissions will be marked in classroom sessions.
Mark Reason for awarding it
0 Empty submission
1 Code submitted but tests and main program won’t compile or run successfully
2 – 3 No compiler errors or runtime exceptions, but some tests are missing or fail, or
the main program doesn’t meet the minimum requirements
4 Minimal set of passing tests; main program runs as expected
5 – 7 Good set of passing tests; main program runs as expected; code quality OK (no
more than 3 distinct issues reported by ktlint and detekt)
8 – 10 Very thorough testing, all tests pass; enhancements implemented; good code
quality (no issues reported by ktlint or detekt)
版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。