CHC4010 DevOps – Example Coursework Assignment
2023-2024
For this coursework you will be doing work debugging, understanding and improving a program that has been provided to you.
You have been provided with the java source code that plays a game where the player chooses a number and the program guesses what that number is. (The game is described in more detail at the end of this document.) Unfortunately, a rather strange and oddly specific glitch has carried the names of all the variables and functions in the program away – literally.
Use a Java IDE to analyse the program using the debugger and code analysis tools, and work out what each variable, parameter, and method does. You should also find and fix the bugs in the program.
You must submit your work before 23:59 on Friday of week 11.
Part of the coursework include a quiz related to the program, and will be taken in class on week 12. Note that you should complete tracing and learning about the program before submitting it at the end of week 11, and doing the quiz on week 12.
Feedback will be provided online once the work has been completed. You may also ask for feedback from your class tutor in any module session, although tutors will not directly tell you the answers to questions.
This is individual work and is subject to the University’s regulations on assessment. Students who plagiarize work from other students, the Internet, or any other source, will be subject to the Academic Conduct Process. Work submitted late without an appropriate Mitigating Circumstances claim or Equality Memo will not be marked. Posting parts of the source code, or of your answer, on the Internet (to solicit answers or for any other reason) is not permitted and will be treated as an attempt to cheat or facilitate others cheating.
Task
Change the name of the variables, parameters and methods to more meaningful names
Add JavaDoc description to each method, describing the input, output of the functions and what they do
Find and fix the bugs
Write automated tests for methods
cakeWalk()andappleJack()with the testing libraryJUnit 5.Use Git to track your progress and make different commits for the four tasks mentioned above with clear commit messages. Your local Git repository should be synced with a remote repository on gitee.com.
Once you have finished refactoring the program, you must submit ONLY the source code file on the student website before the deadline.
Tips
You should use IntelliJ for this exercise.
The file is provided as a bare Java source file. You should create a Project in an IDE and then load the file into it. Do not just open the file raw, as it will not be associated with a JDK and analysis tools will not be available.
You should rename the variables in the source code first as it will make the work much easier. Start by identifying the obvious variables based on the user prompts and the string outputs, rename these, and then see how they are used elsewhere in the program. Do make notes of what you have renamed each variable as the quiz will ask you about this.
The program may use some Java constructions you have not seen before. Tracing the code should help you learn what these do.
Guess My Number
This game is used in math classes as a pedagogical device. The student is asked to pick an integer between 1 and 64 inclusive, without telling the teacher what the number is. The teacher then goes on to display a list of integers (within the aforementioned range), and the student will indicate whether the number they have chosen is found in this list. This process is repeated 6 times. At the end of the game, based on the 6 answers given by the student, the teacher will be able to tell exactly which number they have picked. Can you figure out how this is accomplished?
Our program allows the user to play the role of the student. After asking the user to pick a number in the range 1 to 64 inclusive, the program will print 6 lists of numbers (these lists are randomized and should be different each time the game is played), and each round the user will type “Y” if their number is in the list, and “N” if not. Then the program will print out the number that it decides is the one picked by the user. If the program runs without any bugs and the user gives a truthful answer each time, the guess should always be correct.
An example is given on the next page.
Last updated