[SOLVED] C Scheme game html Java 1

$25

File Name: C_Scheme_game_html_Java_1.zip
File Size: 235.5 KB

5/5 - (1 vote)

1
Programming Fundamentals (48023) Assignment
STUDENTS ARE REMINDED THAT THIS ASSIGNMENT HAS NO INFLUENCE ON WHETHER YOU PASS OR FAIL THIS SUBJECT. PASSING AND FAILING IS SOLELY DETERMINED BY THE PASS / FAIL LAB TESTS.
2 3
4 5
6 7 8
12 13 14
15 16 17 18
19
20 21 22 23 24
25 26
27 28
29
Everything on this page down to the dashed line is extracted from the subject outline, plus some annotations in boxes
Assessment task 2: Assignment
Weight: 30% Part A is worth 10%, Part B is worth 20%.
Task: 11!Due:
. This assignment is an individual work. The assignment is due at
9 10
11:59pm Friday October 18, 2019
However, to be eligible to receive a mark for the assignment, a student must have completed all the pass/fail AND additional lab tests by the last lab session of week 11 (i.e. Friday, October 11).
Students may submit the assignment as many times as they like, without loss of marks, prior to the submission date/time. For feedback, students are encouraged to submit their partly completed assignments to the online test system regularly, prior to the deadline.
Late penalty
Work submitted late without an approved extension is subject to a late penalty of 10 per cent of the total available marks deducted per calendar day that the assessment is overdue (e.g. if an assignment is out of 40 marks, and is submitted (up to) 24 hours after the deadline without an extension, the student will have four marks deducted from their awarded mark). Work submitted after five calendar days is not accepted and a mark of zero is awarded.
End of extract from the subject outline
(i.e. 18/10/2019, 11:59pm).
Programming Fundamentals (48023) Spring 2019 Assignment Page 1

30 Two Parts: A (worth 10%) and B (worth 10%)
31 There are TWO parts to the assignment, called Part A which is worth 10% and Part B which is
32 worth 20%. Both parts have the same deadline. You do not have to do both parts to register a mark for
33 assessment item 2. You can stop doing this assessment item at any time, and whatever marks you have in
34 PLATE at that time will be counted.
35 Minimum Requirements
36 To receive any marks, your solution must meet the following minimum requirements:
37 1. 38
39
40
41 42
43 2. 44
45 3. 46
47
48 4.
49 5.
50 51
You must complete this assessment task in the order of the parts, first part A, and then Part B. You have to use your solution to Part A to do Part B, so you have no option but to do Part A first. But you do NOT need to score full marks on Part A before doing Part B. You will need the full, correct functionality of Part A to do Part B, but you do not need any of the design and indentation marks to start on Part B. (The exact breakdown of marks for Part A is given later in this document.)
Within each of Parts A and B, the tasks must be implemented in the order specified in the Task sections below.
You may only use the features of Java that are taught in this subject. For example, you must not use inheritance, exceptions, varargs (e.g. printf), interfaces, or generics. We want to assess your ability to use the very specific features of Java that we have taught you in this subject.
Your solutions for Parts A and B must NOT use arrays (or equivalent).
Your programs output must EXACTLY match the output given by PLATE. To ensure you meet this requirement, it is highly recommended that you submit to PLATE frequently; at least once on each day that you do any work on the assignment.
52 Assignment submission and return
53 Your assignment must be submitted as a JAR file through the PLATE system, online, at
54 http://plate.it.uts.edu.au/. You may submit and resubmit as many times as you wish, before the due date,
55 and PLATE will update your mark.
56 Instructions for submitting to PLATE are displayed online at the PLATE website.
57 WARNING! PLATE may become overloaded on or near the due date when many students load and test
58 their solution at the last minute. This will not be considered as a valid reason for an extension. To be
59 safe, you should aim to submit your solution well before the due date.
60 Your mark for each part is available as soon as you submit to PLATE.
61 No part of this assignment is manually marked.
62 Further instructions for submitting to PLATE are displayed online at the PLATE website.
Programming Fundamentals (48023) Spring 2019 Assignment Page 2

63 64
65 Late submission
66 See the page 1 extract from the subject outline, Late penalty, for details of late submissions.
67 Permission for an extension must be sought from the subject coordinator before the due date.
68 Applications for an extension that are due to illness will require a supporting medical certificate.
69 Special Consideration
70 If your performance in an assessment item or items has been affected by extenuating or special
71 circumstances beyond your control you may apply for Special Consideration. Information on how to
72 apply can be found at http://www.sau.uts.edu.au/assessment/consideration.html
73 Model solution
74 A model solution can be seen by contacting the subject coordinator via email on or after Monday
75 November 18 (i.e. a month after the due date). This lengthy delay after the due date is because some
76 students are likely to have been granted an extension for sickness, or misadventure (and such
77 illness/misadventure has been documented). Do not email the subject coordinator to request the model
78 solution before Monday November 18, as he will not be maintaining a list of names and thus your
79 premature request may not be answered.
80
Programming Fundamentals (48023) Spring 2019 Assignment Page 3
Submit your assignment here.

81 Regular Submission to PLATE
82 You must submit your progress to PLATE regularly while you are working on each task. This will
83 provide us with a record that you have been doing your own work. If two students submit the same
84 solution, your submission history may be used by the University Student Conduct Committee to
85 determine who did the work and who copied.
86 Academic misconduct
87 Working with another person on this assignment is not allowed and may lead to academic misconduct.
88 Do not show other people your code, or look at other peoples code, or discuss assignment code with
89 other people; it is not right to have a copy of someone elses assignment (before the submission date). Do
90 not post your assignment on the web. Posting your assignment on the web and getting help through
91 blogs, forums or other websites may lead to academic misconduct.
92
93 To detect student misconduct, the subject uses an online system called PLATE available at
94 http://plate.it.uts.edu.au
95
96 Students may find it useful to consult The UTS Coursework Assessment Policy & Procedure Manual, at
97 http://www.gsu.uts.edu.au/policies/assessment-coursework.html
98 Expected work load
99 It is expected that parts A and B will each take about 4 to 10 hours of work, but some people may
100 complete the task in less time, and some students may need many more hours. If a student finds
101 themselves investing a lot of hours in the assignment, the student might consider whether it is worth their
102 time to do this assignment. Remember: the assignment has no effect on whether you pass or fail.
103 Seeking Help
104 Students should make the most of the many opportunities for face-to-face help in lectures and labs.
105 Students are welcome to go to the SECOND hour of ANY lab session to seek help from a tutor.
106 The subject coordinator may answer some questions by email. However, if an emailed question would
107 require a lengthy email reply, a student will be asked to seek help at a lecture or lab session.
108 Students should NOT request help from tutors via email.
109
Programming Fundamentals (48023) Spring 2019 Assignment Page 4

110 Part A (10%)
111 Lines of Code Required: About 80 lines, excluding blank lines
112 Topics: Data flow, OO programming basics, Control flow.
113 Objectives: This assignment supports objectives 1-4 and graduate attributes A1, B2, B5, C3.
114 Students who expect to follow this subject by doing Applications Programming (48024) are
115 STRONGLY ENCOURAGED to do Part A of the assignment to prepare for Applications Programming.
116 NOTE: Unlike the lab tests, there is no skeleton file for the assignment. To start the assignment,
117 select New project off the Project menu, as shown below:
118
119 After creating the project, to create each new class, select New Class as shown below:
120
121 Do NOT save your JAR file to your BlueJ Project Folder
122 Do NOT save your JAR file into the same folder as your BlueJ files for the assignment. When you do
123 that, each time you make a new JAR file, the new JAR contains the old JAR, and eventually you end up
124 with a REALLY REALLY BIG JAR file. The JAR file for benchmark solution used in PLATE is only
125 5KB. Your JAR file should not be much bigger than that.
126
127
128
129
130
131
132
If you have already been saving the assignment JAR file into the same folder as the BlueJ files, then youll need to:
(a) create a new BlueJ project folder,
(b) copy-and-paste your code from the old folder into the new folder, and then
(c) in future, dont save the jar file into this same new folder as the BlueJ files.
Programming Fundamentals (48023) Spring 2019 Assignment
Page 5

133 134
135 You will build a simple game where the players goal is to collect 3 stones and place them in a certain
136 order to unlock a treasure chest and win the treasure.
137
138
139 All the arrows inside the above Figure of a BlueJ window will only appear in your BlueJ
140 implementation when you have completed Part A.
141
142 Tasks
143 These tasks must be completed in the order listed below.
144 Task 1: Classes and Fields / Private Data Members
145 You should create the following classes (written underlined and BOLD) and fields / private data
146 members (enclosed in double quotes):
147 Each Stone has a name (which is a String) and a weight (which is an integer). This takes
Here, Jar is a class. It is NOT short for Java Archive File.
148
about 5 lines of code, ignoring blank lines, and with opening and closing braces on one line each. Programming Fundamentals (48023) Spring 2019 Assignment Page 6

149 150
151
152
153 154
155
156 157
158
Each Jar has a position (which is an integer) and a stone (i.e. instance of class Stone, declared thus Stone stone). This takes about 5 lines of code, ignoring blank lines, and with opening and closing braces on one line each. (Here, Jar is a class. It is NOT short for Java Archive File.)
Each Player has a name (which is a String), a position (which is an integer) and a jar (i.e. instance of class Jar, declared thus Jar jar). This takes about 6 lines of code, ignoring blank lines, and with opening and closing braces on one line each.
The Ground has a player (i.e. instance of class Player), and three instances of class Jar, named jar1, jar2 and jar3. This takes about 5-7 lines of code, ignoring blank lines, and with opening and closing braces on one line each.
159 You must also define an additional class Global, thus: import java.util.Scanner;
public class Global
{
public static final Scanner keyboard = new Scanner(System.in); }
160 Because keyboard has been defined as public static, it can be accessed from any other class in your
161 program; for example:
String name = Global.keyboard.nextLine();
162 In the tasks below, instead of creating a new Scanner in several places in your code, use this global
163 keyboard in all your classes.
164 All class names must begin with an uppercase letter (e.g. Stone) while field names must begin with a
165 lowercase letter (e.g. weight). For compound words, the first letter of the second and subsequent words
166 should be capitalized (e.g. ladyGaGa).
167 All classes must be public and all fields must be private.
168 Code all these classes and fields in a BlueJ project and submit them to PLATE.
169
170
171
172
173
174
175 Task 2: Simple constructors
176 In this task, you will add constructors to some of classes to initialise the program. More than one of your
177 constructors will need to read input from the user. Define constructors for each class as follows, and in
178 the following order.
179 2.1 Stone
180 Define a constructor for class Stone that reads input from the user and initialises the name and weight
181 fields according to the following I/O (bold text indicates sample user input): Programming Fundamentals (48023) Spring 2019 Assignment Page 7
Warning: NEVER save your Java Archive (JAR) file INSIDE your BlueJ project folder. When you create a JAR file, it zips up the entire contents of your project folder. If the project directory already contains a JAR file, that old JAR file is included in the new JAR file. If you do that several times, you end up with a HUGE JAR file that PLATE will not accept.

Enter stone name: Diamond Enter stone weight: 12
182
183 Technical note: In the above example, the nextLine() method will read 8 characters (7 letters plus the
184 newline character), while nextInt() will read only 2 characters (leaving the newline character unread). To
185 avoid any problems after using nextInt(), you should immediately consume the remaining newline
186 character by adding this line:
187
188
189 This constructor takes about 8 lines of code, ignoring blank lines, and with opening and closing braces on
190 one line each. Three of those 8 lines should be (not consecutively):
191 System.out.print(Enter stone name: );
192 System.out.print(Enter stone weight: );
193 Global.keyboard.nextLine();
194 Submit your code to PLATE to receive marks for this part, and do the same for each subsequent part
195 below. You are required to submit your progress to plate while you are making progress.
196 2.2 Jar
197 Define a constructor for class Jar that initialises the position to zero and the stone to null. This takes
198 about 5 lines of code, ignoring blank lines, and with opening and closing braces on one line each.
199 2.3 Player
200 Define a constructor for class Player that asks the user to input their name as illustrated in the box below,
201 where the bold text indicates users input. This constructor also initialises the position to zero, and creates
202 the players jar using new Jar().
203
Enter players name: Joe 204
205 This takes about 7 lines of code, ignoring blank lines, and with opening and closing braces on one line
206 each. One of those lines should be:
207 System.out.print(Enter players name: );
208 Another of the lines should include Global.keyboard.nextLine();
209 Task 3: Advanced constructors
210 3.1 Jar
211 Define another constructor for class Jar that takes two parameters, the initial position (integer) and an
212 instance of class Stone, and uses these parameters to initialise the corresponding fields of the jar (i.e.
213 position and stone). Define this constructor below your existing no-parameters constructor. This
214 takes about 5 lines of code, ignoring blank lines, and with opening and closing braces on one line each.
Global.keyboard.nextLine();
Programming Fundamentals (48023) Spring 2019 Assignment Page 8

215 3.2 Ground
216 Define a constructor (with no parameters) for class Ground that creates the player and creates three jars,
217 where each jar contains one stone. Creating the player will require one line of code, which includes the
218 reserved word new. Creating the three jars will require at least three lines of code, with each line
219 including one or two occurrences of the reserved word new. The stone for jar1 should be in position
220 1, the stone for jar2 should be in position 2, and the stone for jar3 should be in position 3. Hint:
221 when creating each of the three jars, the second parameter to the constructor is new Stone()
222
223 NOTE: TASKS 4 AND 5 REQUIRE A SOLID GRASP OF CLASSES AND OBJECTS. IT IS
224 RECOMMENDED THAT STUDENTS DO NOT SPEND EXCESSIVE TIME ON TASKS 4 AND
225 5.
226 Task 4: move() methods in classes Player and Jar
227 Define a move method for class Player that takes an integer distance as a parameter, which can be
228 positive or negative. When invoked, this distance should be added to the players current position. Define
229 this method compositionally so that when the player is moved, the players jar also moves with the player
230 in the same direction and by the same distance. To implement this compositionally, you will also need to
231 define a move method inside the Jar class so that when the player is asked to move, the player can then
232 tell the jar to move in the same direction. This move method in class Player takes about 5 lines of
233 code, ignoring blank lines, and with opening and closing braces on one line each in other words, the
234 body of the method between the opening and closing braces is two lines of code, where one of those lines
235 is a call to the move method inside the jar. The move method in class Jar takes about 4 lines of
236 code, ignoring blank lines, and with opening and closing braces on one line each in other words, the
237 body of the method between the opening and closing braces is a single line of code.
238 Task 5: pickUp() method in class Player
239 Add the following method to the class Jar:
240 public void moveTo(Jar jar)
241 {
242 jar.stone = stone;
243 stone = null;
244 }
245 Define a pickup method for class Player that takes an instance of class Jar as a parameter. This
246 pickUp method takes 4 lines of code, ignoring blank lines, and with opening and closing braces on one
247 line each in other words, the body of the method between the opening and closing braces is a single
248 line of code. When this pickUp method is invoked, the stone contained in the given jar passed as a
249 parameter should be removed from that jar and stored into the players jar. This is done in a single line of
250 code by making a call to the method moveTo inside the instance of class Jar which was passed as a
251 parameter. The parameter for moveTo is the field / private data member of class Jar in this class
252 Player.
253
Programming Fundamentals (48023) Spring 2019 Assignment Page 9

254 Marking scheme for Part A
255 Your solution will be marked according to the following scheme:
256 Correct indentation means that code should be shifted right by one tab between { and }.
257 Note: PLATE shows marks out of 100. That PLATE mark will be converted to a mark out of 10. When
258 making that conversion, the mark out of 10 will be rounded to the nearest integer. Thus, a mark of 95
259 out of 100 is 9.5 out of 10, which will be rounded to 10. There is therefore no point to trying to
260 achieve a mark higher than 95 out of 100.
261
262 Note: You have to use your solution to Part A to do Part B, so you have to do Part A first. But you do
263 NOT need to score full marks on Part A before doing Part B. You need PLATE to award you a PASS
264 for Tasks 1-5, but you do not need the indentation marks to start on Part B.
265
Task 1: Classes and fields Task 2: Simple constructors Task 3: Advanced constructors Task 4: move() method
Task 5: pickUp() method Correct indentation
20 marks 20 marks 25 marks 10 marks 15 marks 10 marks
Mark out of 100
Mark out of 10
95
10
85
9
75
8
65
7
55
6
Programming Fundamentals (48023) Spring 2019 Assignment Page 10

266 Part B (20%)
267 Lines of Code Required: About 200 lines, excluding blank lines
268 Topics: Data flow, OO programming basics, Control flow.
269 Objectives: This assignment supports objectives 1-5 and graduate attributes A1, B2, B5, C3.
270 In Part B of the assignment, you will finish the game that you started building in Part A, using your
271 solution to Part A as a starting point.
272 Tasks
273 These tasks must be completed in the order listed below.
274 Task 1: Chest
275 Define a public class Chest according to the following description.
276 A Chest has an integer combination, an integer position and 3 jars (jar1, jar2 and jar3). The
277 constructor for class Chest should read the combination from the user according to the following I/O:
278
Enter chest combination (5-10): 7
279 The chest should be created at position 4, and 3 empty jars should be created at the same position as the
280 chest itself.
281 Update the definition of class Ground to reflect that the ground has 1 player, 3 jars and a chest.
282 Before continuing, make any necessary changes to your existing code to ensure that all constructors,
283 methods and classes are public and all fields are private.
284 Note!! Your Part B solution should be submitted on PLATE under the link Treasure Part B
285 2019 Spring. Be careful not to submit under the link for Part A.
286
287 Task 2: Unlocking the chest
288 It is necessary for your program to detect when the player has placed all 3 stones on the chest in the
289 correct order in order to recognise that the game is over. The chest is locked with a combination chosen
290 by the user. A set of 3 stones A,B,C placed on the chest will unlock the chest only if the weight of A plus
291 the weight of B multiplied by the weight of C equals the combination. i.e. A+B*C=combination.
292 Define a method in class Ground called isChestUnlocked() which is public, takes no parameters and
293 returns a boolean. This method should return true if and only if all 3 stones have been placed on the
294 treasure chest in the correct order as described above.
295 Task 3: toString() method
296 Define a public toString() method on class Ground that returns a String in the following format:
297
298
Programming Fundamentals (48023) Spring 2019 Assignment Page 11
Jack[](0) [Quartz#4](1) [Pearl#3](2) [Opal#2](3) /6(4)

299 This string describes the player Jack with an empty jar at position 0, three jars at positions 1, 2 and 3
300 containing rocks named Quartz, Pearl and Opal with weights of 4, 3 and 2 respectively, and the
301 chest with combination 6 at position 4. The numbers and names may of course differ depending on what
302 data is entered by the user when the constructors are executed. Thus, your string should always
303 incorporate data directly from the fields. If the chest is unlocked, it should be rendered as 6/(4) instead
304 of /6(4).
305 This task must be implemented compositionally with a toString() method in each class. The String
306 returned by this method can embed variables this way: return string1 + string2 + variable + another
307 string + You can also use the StringBuffer class described in the text book. You must not, however,
308 use the sprintf method (since it uses the untaught varargs feature).
309
310 Task 4: turn() method
311 Define a method in class Ground called turn() which is public, takes no parameters and returns nothing.
312 This method allows the player to have his/her turn by asking the user to type in some command, either l
313 to move the player left, r to move the player right, p to pick up a rock at the current position or d to
314 drop a rock at the current position.
315 Your method should follow exactly the following output format:
Move (l/r/p/d): r
316
317 Your program must print the prompt Move (l/r/p/d): and then read the users input.
318 6. 319
320 7. 321
322
323
324 8. 325
326
If the user types l or r, your program should send a message to the player object to move one position to the left or right respectively.
If the user types p, your program should send a message to the player to pick up a rock from a jar on the ground at the current position. This command does nothing if the players jar already contains a rock. Note that you should apply good design principles to simplify your code, since you will also receive marks for the quality of your design.
If the user types d, your program should send a message to the player to drop a rock into a jar on the ground at the current position. This command does nothing if there is already a rock in a jar at that position. (You should define any additional methods as necessary)
327 You do not need to try all of this task at once. Complete a little bit at a time, and submit to PLATE to see
328 your progress and receive PLATEs feedback.
329 Task 5: Placing rocks on the chest
330 Modify the behaviour of the p (pickup) and d (drop) commands so that if the players current position
331 is the same as that of the chest, a rock will be picked up from, or dropped onto the chest. Because the
332 chest contains 3 jars at identical positions, picking up and dropping rocks over the chest follows priority
333 rules:
334 335
336 337
When dropping a rock, jar1 is tried first, and if it already contains a rock, then jar2 is tried, and then jar3.
When picking up a rock, the player looks in jar3 first, and if no rock is in there, then jar2 is tried, and then jar1.
Programming Fundamentals (48023) Spring 2019 Assignment Page 12

338 Task 6: Loops
339 You will now implement some loops in your program. After completing each loop, submit it to PLATE
340 to receive marks and feedback for that loop.
341
342
343
344
345
346
347
348
349 350
351
352
Loop 1: Define a method in class Ground called play() which is public, takes no parameters, and returns nothing. This method repeatedly invokes the turn() method until the treasure is unlocked and the game is over. When the loop stops, the program should print You unlocked the treasure!. You should also print out the toString() representation of the ground before each turn and after the last turn. You can test this method in BlueJ by right-clicking on the Ground class to create a new Ground, and then right-clicking on the created object and selecting the play() method.
Loop 2: When the user is asked to specify the treasure chest combination, this number must be within the range 5-10. Write a loop which repeatedly asks the user to enter a number until the user enters a valid number within the range 5-10. Your output should follow the following format exactly:
353 Enter chest combination (5-10): 4
354 Invalid combination.
355 Enter chest combination (5-10): 2
356 Invalid combination.
357 Enter chest combination (5-10): 12
358 Invalid combination.
359 Enter chest combination (5-10): 5
360
361 As you attempt each loop, submit your project to PLATE to see the expected input/output, and adjust
362 your code to comply with PLATEs output.
363 After you have done this, define a class called Main, which has a correctly defined main() method
364 according to the lecture notes. This method should create a new Ground object, and then invoke its play()
365 method.
366
Programming Fundamentals (48023) Spring 2019 Assignment Page 13

367 Marking scheme for Part B
368 Your solution will be marked according to the following scheme:
Task 1: Task 2: Task 3: Task 4: Task 5: Task 6: Correct Design
Chest
Unlocking the chest toString() method
turn() method
Placing rocks on the chest Loops
indentation
5 marks 10 marks 20 marks 15 marks 15 marks 10 marks 5 marks 20 marks
369 Correct indentation means that code should be shifted right by one tab between { and } and within
370 nested control structures such as if statements, switch statements and loop statements. In a switch
371 statement, the code within each case should also be indented. NOTE: You are responsible for your own
372 indentation. Do not rely on BlueJ to indent code for you. BlueJ does not always indent code in the way
373 that is required.
374 Design marks are awarded for the quality of your solution. More marks are awarded for placing code
375 into the most appropriate classes so as to increase cohesion and reduce coupling. (To understand
376 coupling and cohesion better, google the words java tutorial coupling cohesion.)
377 Note: PLATE shows your Part B mark out of 100. When calculating your final grade, that PLATE mark
378 will be converted to a mark out of 20. When making that conversion, the mark out of 20 will be rounded
379 to the nearest integer. Thus, a mark of 98 out of 100 is 19.6 out of 20, which will be rounded to 20.
380 There is therefore no point to trying to achieve a mark higher than 98 out of 100. Also, a mark of
381 93 out of 100 is 18.6 out of 20, which will be rounded to 19, so students should consider whether it
382 is a good use of their time to try to increase their part B mark from 93 to 98, just to get 1 more
383 mark. And so on
384
Mark out of 100
Mark out of 20
98
20
93
19
88
18
83
17
78
16
73
15
68
14
385
Programming Fundamentals (48023) Spring 2019 Assignment Page 14

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[SOLVED] C Scheme game html Java 1
$25