Need Help-COSC1073 – Programming 1


Need Help-COSC1073 – Programming 1  
Semester 2 2016  Programming 1 (COSC1073)  PART C Specification – ASCIIBot Robot Implementation
_________________________________________________________
Overview This semester you have a single assignment topic which is broken down into three parts A, B and C.
Assignment Part A (5%), due 11:59PM Fri. 12th August 2016 Assignment Part B (15%), due 11:59PM Fri. 16th September 2016 Assignment Part C (20%), due 11:59PM Fri. 14th October 2016
This specification builds upon your part B solution however it can be done without a fully working part B since there is no error checking or collision detection.
PART C Requirements (due 11:59PM Fri. 14th October 2016).
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 interface called the ASCIIBot!
Don’t panic you don’t have to deal with complex 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 art. The Robot project has been updated to include the lanterna-2.1.7.jar file and includes code which shows you how to initialise and draw characters at a specific x,y co-ordinate. You should not need to but if you are interested you can find more information about other extra functionality of Lanterna here:
https://code.google.com/archive/p/lanterna/wikis
NOTE: The primary specification is the supplied video “PartC.avi” which shows the full behaviour you should reproduce.
Your task is implement the Robot interface by writing code (@Overrides) in the ASCIIBot for all the specified Robot interface methods (init(), pick(), drop() etc.).
Full marks will be achieved using an Object-Oriented solution that includes the following four classes and an interface.

COSC1073 – Programming 1
public class ASCIIBot implements Robot
public class Arm implements Drawable
public class Bar implements Drawable
public class Block implements Drawable
Where the interface Drawable is specified as follows:
public interface Drawable {   public abstract void draw(Terminal terminal); }
These classes give you a basic design where each of the components of the robot environment are able to draw itself to the terminal. You may also find it useful to include an extra abstract class as follows (this is how I did it and it reduces some code duplication):
public abstract class AbstractItem implements Drawable
If you do this then Bar and Block can extend AbstractItem instead of implementing the Drawable interface directly.
Skeleton code for all of these classes is provided in the supplied Robot-PartC eclipse project. It also draws a single block 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 API docs.
If you are having trouble getting started you can instead work on a non-OO solution which can still get a pass mark if fully functional but the real objective of this assignment is to demonstrate application of inheritance, polymorphism, abstract cases and interfaces (otherwise you are not really learning much beyond assignment part B).
In addition to drawing the various components (bars, blocks and arm) 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)

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.
COSC1073 – Programming 1

Do any scaling although you may wish to do this as a challenge once you are finished to make the implementation look better.
Suggestions on How to Proceed
To get started you should experiment and familiarise yourself with the Lanterna moveCursor() and putCharacter() methods. They are straight forward i.e. move to a row, col position and then draw a character. An example is provided in the Bar.draw() method.
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).
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.
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 fixed starting position using some basic maths and array processing to position them.
Finally for each movement command ( up(), down(), pick() drop() etc .) keep track of the positional changes (using appropriate variables) and redraw the entire screen.
You will run your ASCIIBot using the following main() method:
public static void main(String[] args)  {   new RobotControl().control(new ASCIIBot(),null, null);  }
This simply creates a new instance of your RobotControl() class from part B 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: Do not change the Control interface or the calling of the RobotControl.control() method since we will rely on this for testing using our own RobotControl implementation.
COSC1073 – Programming 1
Summary
Write code using classes, an interface, loops, conditionals and methods to reproduce the behaviour shown in the video PartC.avi (and optionally PartC Scaled (Optional).avi) and elaborated above.
Code Quality Assessment
As well as functional correctness (robot behaviour matches video requirements) you will also be assessed based on code quality requirements specified in assignment part A.

Need Help-COSC1073 – Programming 1

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: