Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

编程代写|INST0004 Programming 2 Late Summer Assessment

编程代写|INST0004 Programming 2 Late Summer Assessment




All the questions below are assessed and so marked with a [*]. You have been assigned one or more of these questions as alternative assessments. Questions on the sheet are numbered according to the Tutorial assessment to which they relate. You must submit your answers to the appropriate questions on Moodle by 3pm on Wednesday 31st August 2022. You will then be asked about a selection of your answers in a viva scheduled either on Friday 2nd September 2022. You will receive a separate email specifying the exact, slot, date and time of your viva. The purpose of the viva is to check that you understand why your answers work in the way that they do, and that you understand the associated programming concepts covered in the lecture videos. To pass the assessment, you must both submit adequate answers to the questions and pass the viva. Your exact grade will be based primarily on your performance in the viva.

Please submit the completed files to the Submission link for deferred submissions on the Late Summer

Assessment version of the INST0004 Moodle page.

To get started, download the .zip file available on the Moodle page. This contains some provided code needed for the questions. The Zoom link for your viva will be provided to you.

Accumulator [*]

Look at the Accumulator and AccumulatorProg classes in the folder.

The Accumulator class creates objects that accumulate all the Strings that are given to them into one long String. There is one missing attribute, history and two missing methods that are called in AccumulatorProg: update and getHistory.

You will complete the Accumulator class to make the AccumulatorProg programme run properly. You should make the following changes to Accumulator:

a) Add String attribute history

b) Complete the constructor provided so that it initialises history as the empty String, “”

c) Add a method update which takes a single String as input and returns nothing. The method should extend history by the characters in the input String (concatenation). For instance, if history has value “Initial” and the input argument has value “Added” , then after the method call history should have value “InitialAdded”.

d) Add a getter method getHistory that returns the value of the history After implementing these methods, compile both classes. Can you predict what will be output when AccumulatorProg is run? Run it and see if you predicted correctly? Can you explain this output once you have seen it?

Submission: You should submit and to the LSA submission link on the Assessment section.

Spot the Ball [*]

Look at the MagicBox and SpotTheBall classes in folder spot the ball.

Look at the MagicBox. This class represents a magic box with 5 doors that randomly hides a single ball behind one of the doors. Before attempting to compile it, predict whether or not it will compile. Now try compiling MagicBox. Is the result as expected?

The SpotTheBall class contains a main method representing interactions with two MagicBox objects. Look at this class and predict whether or not it will compile. Does it compile?

If either class fails to compile, what do the errors mean?

You will complete the MagicBox class to make the SpotTheBall programme run properly. Implement

MagicBox to meet the following requirements:

a) A constructor has been declared for you but does nothing. This should create an int array of size 5 and assign it to the doors attribute, then call the randomiseBall method.

b) The attribute doors should not be accessible from outside of the class. Set the visibility of doors appropriately to ensure this.

c) Add a method checkDoor which takes a single int as input and returns nothing. The input corresponds to a guess of where the ball is. If this guess is correct, the method should output that the ball is behind that door and then call randomiseBall . If the guess is incorrect the method should simply output that the door contains nothing.

d) Add a method peek that takes no input and returns nothing. When called this method should output which door the ball is behind. After implementing these methods, now compile both classes and run SpotTheBall . Play the game. Can you explain the behaviour?

What will happen if you uncomment line 18 in SpotTheBall ? Can you explain the new behaviour?

Submission: You should submit and to the LSA submission link on the Assessment section.