Page 1 of 7 KXO 151 Programming & Problem Solving AIEN -SOU - 2023
Assignment 3 Due Date & Time : 9PM (Shanghai) Friday, Week 14, 26 May, 2023 Maximum Weight : 30% (of the total assessment for KXO 151 ) Submission: Via MyLO NOTE: All assignments will be checked for plagiarism by a specialist Java program that checks your assignment against other student’s assignments as well as the Internet (including help sites). For more information see: www.ics.heacademy.ac.uk/resources/assessment/ plagiarism/demo_jplag.html Assignment Type: Group: 2 students in each group. Students are free to choose who they join with. A group sign -up sheet is available on the KXO151 MyLO site .
NOTE: Students who have not signed into a group by Friday , 12 May, 20 23, will be assigned into a group without consultation.
NOTE: Each contributing student within the group will receive the same mark, however, active participation and equal contribution is re quired from each member of the group. Students who are found to have not participated and / or equally contributed to the assignment work will not be included in the group’s mark. If there is an issue with a student not participating and / or contributing to your group, please contact your lecturer. Cover Sheet: The School requires that a group cover sheet listing the members of your group be submitted with your assignment.
The Programming Task
Beware - the version that you implement must match the specifications given below and use the resources provided. Other implementations will score poorly. The code you are to write is to complete an implementation of the activity "A Week is a Long Time in Politics". In this game the user plays the role of the Deputy Premier of a fictitious state (called Taswegia) of a fictitious country (called Straya). The Deputy Premier has agreed to appoint a new magistrate but has allegedly been influenced to change his mind. A memorandum appointing the first magistrate has been written, but a second memorandum with a different name on it has also been submitted. The Deputy Premier is under pressure as others attempt to discover what may have occurred. The user will win the game if he/she can keep the Deputy Premier in the j ob for 7 days.
The user is able to control what the Deputy Premier does from day to day. Options include giving a response of "No Comment!" when approached, denying (in Parliament) any wrong doing, shredding the original memorandum (if it is in his possess ion and the shredder isn't full), holding a secret meeting with the Chief Assistant of the Premier , or resigning. If he resigns the game is over. Different consequences exist for the Deputy Premier's behaviour. These include: none, a story in the local pap er, the original memorandum being stolen, the original memorandum being presented in Parliament, and the Premier sacking the Deputy Premier. If sacked, the game is over.
When the Deputy Premier has the document in his possession he is reminded of this at the start of each day. He is also told which number day he is up to, how full his shredder is, and, whether he feels worried for his future. The completed implementation w ill consist of 3 files, only one of which must be written by you. These files are: • Asst3.java - This is the driver program (with a main() method). The code of this is complete and it MUST NOT be changed. The code in this file is very simple - it declares and instantiates an object of the AWeekIsALongTime class. • DeputyPremier.java - This file contains resources that you are to use in develop ing your implementation of the game. The code is complete and MUST NOT be changed . • AWeekIsALongTime.java - This is the file that you are to write. There is a "skeleton" version of the code - use this as the starting point for your program. o There will be no main() method in the class, it will contain methods that organise the game. This will include all the interactions with the user. o You should make sure that you do the following: ▪ Create and use object(s) of the DeputyPremier class. You will LOSE MARKS i f you write code in AWeekIsALongTime.java that duplicates things that could be done using methods of the DeputyPremier class. ▪ Use the trace() method (provided in the skeleton) to include tracing messages in your program - switch the messages off before submission. ▪ Use separate methods to implement the separate tasks within the game. ▪ Use instance variables to store data that is used or changed by more than one method. ▪ Use local variables to store the data that is used by just one method.
Details on Writ ing C ode in AWeekIsALongTime .java Write code in AWeekIsALongTime.java to do the following: • "Housekeeping" tasks o Switch off the debugging messages in DeputyPremier objects and the AWeekIsALongTime class. o Whenever a DeputyPremier object is created make a call to its setUp() method with the parameter value 0. • Introduction o Provide the user with a general description of the game. • Play the game - the user is prompted to undertake "actions" until the game is over. o The game will end when any one of the following happens: ▪ The Deputy Premier survives in the job for 7 days (user wins). ▪ The Premier sacks the Deputy Premier (user loses). ▪ The Deputy Premier resigns (user draws). KXO151 - AIEN -SOU – Assignment 3 - 2018
Page 3 of 7 o Before each move the user is provided with the following information: ▪ The current day number. ▪ The events (rumours) of the week so far. ▪ The percentage their shredder is full. ▪ Whether or not the original memorandum is in their possession (unshredded), and whether or not they are worried (instinct value of at least 6). o The user is asked what they want to do on this day. The options are: ▪ Make No Comment or Deny All Knowledge. ▪ The consequences of this action will be calculated and if they are fired the game will end, otherwise a message will be displayed. ▪ Shred the Document. ▪ If they don't have the document, or if the shredder is full, they'l l be told it can't be shredded. ▪ If the document can be shredded then it is, t he consequences of doing so will be calculated and if they are fired the game will end. ▪ Holding a secret meeting with the Chief Assistant of the Premier . ▪ The consequences of this action will be calculated and if they are fired the game will end, otherwise a message will be displayed. ▪ Resign their position. ▪ The game will end (in a draw) o After the action has been taken, the user (if the game isn't over) is shown the current rumours . • Before playing, the user is asked whether or not they want to play, if not, there is no game played. • After each game is over, the user is asked whether they wan t to play again. • When the user does not want to play any more games - there are final messages showing: o How many games were played. o How many games were won by the user. o How many games were lost by the user. o How many games were drawn. A sample output of th e assignment is enclosed within this assignment information package . Use it as a guide to develop your version of the game.
Planning The first thing that you need to do is to understand what uses can be made of objects of the DeputyPremier class . To do this: • Read the code carefully, making sure that you can identify o instance variables o methods - read the header comments and the code of these and work out what they do. • Write a driver program to instantiate an object of the DeputyPremier class and ca ll its methods (to check that they behave the way that you think they do). • Plan how to write code to "org anise" the game (using object(s) of the DeputyPremier class
o Work out the subtasks that will be needed (each of these should be implemented as a method). o Work out the data that will need to be "shared" by more than one method. These will usually be implemented with instance variables. o For each method work out: ▪ the data it will need to have passed in (parameters) ▪ the data it will need to pass out (r eturn value) ▪ the algorithm for doing the subtask • Implement each step after you have planned it - a little bit at a time - compile and test the implementation as you go. Documentation Your program files should be fully documented, at least to the same stand ard as demonstrated in the textbook. This includes in -code comments, descriptions, and where appropriate, explanations for each new constructor, method and variable. Documentation also includes the layout of the Java code and the data printed out to the sc reen, which should both be in a clear and professional format. Important Notes: PLEASE NOTE: This assignment is to be completed by students in groups of 2. If you need help, please look at the textbook or ask your lecturer. Students who have been working through the tutorial exercises should have no difficulty in completing this assignment.
PLEASE NOTE: The submitted Java code must be able to be compiled from the command line using Javac the Java programming language compiler command, or from a ba sic editor such as jGrasp. Be aware that development programs such as Eclipse often use features only available when run using their system, meaning that their code may not run on a system without their development program. Programs that do not run from th e command line using javac (to compile) and java (to run) because of a missing development program feature will fail the assignment.
• Changing a few variable names, adding different data and / or adding your name to the top of someone else’s code does no t make it your own work. See the section on ‘Plagiarism’ below. • Before you submit your assignment through the KXO151 MyLO website, it is suggested that you make sure the final version of your Java program file compiles and runs as expected – do not change the names of the java file – submit it exactly as you last compiled and ran it. PROGRAMS THAT DO NOT COMPILE AND / OR RUN WILL FAIL THE ASSIGNMENT . If in doubt, you can click on the submitted files, download them from MyLO, and check that they are the file s you think they should be. • Only one complete submission is required from each group. • It is up to the members of the group to make sure their assignment files have been submitted correctly. Program Style Your program should follow the coding conventions introduced in this unit and shown in the textbook, especially: • Variable identifiers should start with a lower case letter • Final variable identifiers should be written all in upper case and should be declared before all other variables
• Every if -else statement should have a block of code for both the if part and the els e part (if used) • Every loop should have a block of code (if used) • The program should use final variables as much as possible • The keyword continue should not be used • The keyword break should only be used as part of a switch statement (if required) • Opening and closing braces of a block should be aligned • All code within a block should be aligned and indented 1 tab stop (approximately 4 spaces) from the braces marking this block Commenting: • There should be a block of header comment which includes at least • file name • your name (in pinyin) • student UTas id number • a statement of the purpose of the program • Each variable declaration should be commented. • There should be a comment identifying groups of statements that do various parts of the task. • There should not be a comment stating what every (or nearly every) line of the code does - as in: num1 = num1 + 1; // add 1 to num1
Guide to Assessment and Expectations: The assessment of Assignment 3 is based on the following criteria: Criteria High Distinction Distinction Credit Pass Fail Working Java Classes / Program Provided a complete working set of Java classes that fully satisfy the requirements stated in the assignment requirements, including easy to use interface, using Arrays, and correct use of names Provided a complete working set of Java classes that satisf y the requirements stated in the assignment requirements, including easy to use interface, using Arrays, and correct use of names Provided a complete working set of Java classes that satisfy the major requirements stated in the assignment requirements, including a relatively easy to use interface, using at least 1 Array, and correct use of names Provided a complete working set of Java classes that satisfy most of the major the requirements stated in the assignment requirements, including a usable interface Failed to provide a complete working set of Java classes that satisfy the requirements stated in the assignment requirements & / or fail to compile & / or run Documentation Provided complete documentation of all significant & relevant aspects of the Java classes. Submission of correct & correctly named files, & coversheet Provided reasonably complete documentation of significant & relevant aspects of the Java classes. Submission of correct files & coversheet Provided good documentation of significant & relevant aspects of the Java classes. Submission of correct files & coversheet Provided some documentation of significant & relevant aspects of the Java classes. Submission of correct files & coversheet Failed to provide documentation of significant & re levant aspects of the Java classes, & / or failed to submit coversheet Overall Program Design (Understanding of Java) Demonstrated excellent clear and logical design skills – shows considerable evidence of planning at a very professional Demo nstrated very good design skills – shows evidence of being planned in a logically way. Program is a very Demonstrated good design skills - shows evidence of being logically desig ned and a good solution to the programming Demonstrated basic design skills – shows some evidence of being a logically designed solution to the programming Failure to demonstrate adequate understanding of the nature of Java.
level. Design is logical, and is a complete solution to the programming problem. Shows evidence of thorough testing of the solution good solution to the programming problem, and is a thoroughly tested solution problem. Is an adequately tested solution problem, and most of the methods return the correct values Little or no evidence of any planned design – little or no form or structure. Note The High Distinction grade is reserved for solutions that fully meet the requirements & are highly dis tinguished from other assignments by their high quality work , their attention to detail , & by demonstrating a high -level an understanding and ability to program using the Java language (usually only 10% of students).
Submitting Your Assignment Only one complete submission is required from each group. You need to submit your assignment package containing the following 3 files to the unit MyLO site : Asst3.java , DeputyPremier.java , AWeekIsALongTime.java Follow these steps to create a package for your assignment files and then submit your package file:
- Ensure that you add the names and the UTAS ID numbers of both students of your group into the class header of each of the 3 files, as comments.
- On your computer desktop, create a new folder using your name s and UTAS ID number s. For example, if you r group members are Chen Jianwen ( 121212) and Wu Hao (343434) , then the new folder must be named Chen_Jian_121212_WuHao 343434 .
- Copy your 3 assignment files into the new folder .
- Compress the new folder and name it as a RAR file (or ZIP file). For example, the above group folder would be name d as Chen_Jian_121212_WuHao 343434 .rar, or Chen_Jian_121212_WuHao 343434 .zip.
- Submit your RAR file (or ZIP file) to the unit MyLO site . While submitting, include the names and UTAS ID numbers of both students as comments.
You must also submit a signed group coversheet to MyLO by the assignment due date. The group coversheet is also on the unit MyLO site, under Assessment.
In submitting your assignment you are agreeing that you have read the “Plagiarism and Academic Integrity” section below, and that your assignment submission complies with the assignment requirement that it is your Group’s own work.
Students who believe that this method of submission is unsuitable given their personal circumstances must make alternative arrangements with their Lecturer prior to the submission date.
Extensions will only be granted under exceptional conditions, and must be requested with adequate notice on the Request for Extension forms. Plagiarism and Academic Integrity While students are encouraged to discuss the assignments in this unit and to engage in active learning from each other, it is important that they are also aware of the University’s policy on plagiaris m. Plagiarism is taking and using someone else's thoughts, writings or inventions and representing them as your own; for example downloading an essay wholly or in part from the internet, copying another student’s work or using an author’s words or ideas wi thout citing the source.