COSC1073 – Programming 1
Semester 2 2017
Programming 1 (COSC1073)
PART B Specification – ASCIIBot Robot Implementation
_________________________________________________________
Overview
This semester you have a single assignment topic in two parts (Part A and B)
Assignment Part A (15%) due 9:00AM Mon. 4th Sept 2017
Assignment Part B (20%) due 9:00AM Mon. 9th Oct 2017
This specification builds upon your part A solution however it can be done without a working
part A since there is no error checking or collision detection and the provided ASCIIBot
skeleton code responds to manual keyboard control in the same way as the part A RobotImpl.
PART B Requirements (due 9:00AM Mon. 9th Oct 2017).
Ok so now you are going to do your own complete Robot program! You are no longer going
to use the supplied RobotImpl but are instead going to write your own implementation of the
Robot interfaces called the ASCIIBot. Well ok not from scratch, since we have given you a
fair bit of code to get you started 🙂
Don’t panic you don’t have to deal with real graphics for this assignment since we are going
old school and are using the Lanterna terminal emulator package to allow you to do basic
ASCII drawing. The Robot P1 Part B Eclipse project includes the lanterna-3.0.0.jar
file and includes code which shows you how to initialise and draw characters at a specific x,y
(col/row) co-ordinate. You do not need to, but if you are interested you can find more
information about other extra functionality of Lanterna here:
http://mabe02.github.io/lanterna/apidocs/3.0/
https://mvnrepository.com/artifact/com.googlecode.lanterna/lanterna/3.0.0
NOTE: The primary specification is the supplied video “PartB Solution.avi” which
shows the full behaviour you should reproduce.
You have been given skeleton code that provides all of the required classes and interfaces.
The only new interface beyond assignment part A is the following Drawable interface.
public interface Drawable
{
public abstract void draw(SwingTerminalFrame terminalFrame);
}
COSC1073 – Programming 1
Along with the other provided classes, this gives you a basic design where each of the
components of the robot environment is able to draw itself to the terminal by implementing
the draw() methods. You may also find it useful to include an extra abstract class as follows
(this is how we did it and it reduces some code duplication):
public abstract class AbstractItem implements Drawable
If you do this then Bar, Block and even the Arm class can extend AbstractItem instead of
implementing the Drawable interface directly.
Skeleton code for all of these classes is provided in the supplied Robot P1 Part B eclipse
project. It also manually draws a single ‘bar’ to show you Lanterna code in action since this
is the only part of the assignment that is not specified by standard Java and described in the
standard Java API docs.
In addition to drawing the various components (bars, blocks and arm segments) your
ASCIIBot class will need to keep track of the current position of all bars and blocks as it
responds to commands from the Robot interface.
However it does NOT need to:
● Do any control of its own (this is still done by the RobotControl class) or manually
using the same key bindings as assignment part A
● Do any error checking. i.e. if invalid commands are given your code will either ignore
them or drop blocks in the wrong position, morph through objects etc. i.e. we will test
with correct control code.
Suggestions on How to Proceed
To get started you should experiment and familiarise yourself with the Lanterna
setCursorPosition() and putCharacter() methods. They are straight forward i.e. move
to a col (x) and row (y) position and then draw a character. An example is provided in the
ASCIIBot.demoDraw() method. NOTE: Screen co-ordinates are 0,0 is top left so you need to
do some translation!
Next you should implement the draw() method for the Block and Bar classes so that they
can be drawn at a fixed arbitrary position (no need to worry about moving them yet). Use the
colors and number the bar size as shown in the video.
Next do the same for the Arm class. This one is a bit more complicated since drawing the arm
involves drawing all three segments. In fact you can choose to have a separate class for each
arm but for simplicity a single class works fine.
COSC1073 – Programming 1
Once the three robot environment components (Arm, Bar, Block) are able to draw
themselves, the final and most challenging piece of the puzzle is to keep track of the internal
state of the arm, bars and blocks and draw them in the correct position.
i.e. first handle the init() case when the bars and block arrays are passed in and draw them
at the correct starting position. This is also the right place to initialise all of the data structures
that will be used to keep track of positioning in the robot environment when you perform
subsequent moves.
Finally for each movement command ( up(), down(), pick() drop() etc .) keep track of
the positional changes (using appropriate variables/data structures) and redraw the entire
screen.
You will run your ASCIIBot using the provided main() method:
public static void main(String[] args)
{
new RobotControl().control(new ASCIIBot(),null, null);
}
This simply creates a new instance of the RobotControl() class from part A and executes
the control method which will then call init() and execute commands on your ASCIIBot.
NOTE: There is no special trick to the animation/movement. But rather every time a robot
movement command is issued, you redraw everything at the updated co-ordinates. If you are
clever you can do this polymorphically with draw()!
IMPORTANT: As with Part A do not change any of the provided interfaces such as
Control, Robot or RobotMovement since we will rely on these for testing using our own
RobotControl implementation. Additionally Part B is compatible with your Part A
RobotControl implementation so you may wish to copy this in at the start.
Summary
Write Object-Oriented code using classes, interfaces, loops, conditionals and methods to
reproduce the behaviour shown in the video PartB Solution.avi and elaborated above.
NOTE: All of the robot colors, sizes etc. follow part A for consistency. To obtain full marks
you must implement the provided methods in the provided classes. If these are unused then
you are doing something wrong so please seek help.
COSC1073 – Programming 1
Code Quality Assessment
As well as functional correctness (robot behaviour matches video requirements) and
following the provided object-oriented design, you will also be assessed based on the basic
code quality requirements specified in assignment part A.
Submission Instructions
● You are free to refer to textbooks and notes, and discuss the design issues (and
associated general solutions) with your fellow students; however, the assignment
should be your own individual work.
● You may also use other references, but since you will only be assessed on your own
work you should NOT use any third party packages or code (i.e. not written by you)
in your work.
The source code for this assignment (i.e. complete compiled Eclipse project) should be submitted as
a .zip file by the due date. You can either zip up the project folder or use the Eclipse option
export->general->archive. You will be provided with specific submission instructions on
blackboard before the deadline. You do not need to re-submit your part A solution or project, only
Part B.
当前位置:天才代写 > JAVA代写,java代考-JAVA作业代写免费Moss检测 > Programming 1 (COSC1073) PART B Specification – ASCIIBot Ro
Programming 1 (COSC1073) PART B Specification – ASCIIBot Ro
最后更新 2017-09-07 08:00 星期四 所属:
JAVA代写,java代考-JAVA作业代写免费Moss检测 浏览:1060