View the step-by-step solution to:

Question

Pass Mark

For a pass mark, there must be a display window of size (600, 360) containing a grid with the same

number of columns and rows (10 in the video). Your program should work correctly with a different size and/or number of partitions.


You set a constant globally at the VERY TOP, as:


   final int N_PARTITIONS = 10;

and use it (N_PARTITIONS) throughout the program. your program should work even if the marker changes the value of N_PARTITIONS to 5 or 8 or 15 or ... (obviously, when N_PARTITIONS changes to 15, there should be 15 rows and 15 columns)


When you click anywhere on the display window, circle of diameter 10 (henceforth called a node) should be displayed at that point. Nodes from previous clicks should stay on the screen and there should be lines that join each node with the next one (and the last is joined to the first node). There should be no other lines besides these lines (and the grid lines of course).


For example, if the sequence of clicks is:


Time x: (200, 400)


Time x + 20: (300, 300)


Time x + 70: (60, 100)


There should be nodes drawn at the three points and lines from (200, 400) to (300, 300); (300, 300) to (60, 100); and (60, 100) to (200, 400).


IMPORTANT: You may assume that the maximum number of nodes is 100.


The most useful material for this part is compound data, in particular, arrays - and loops.


Credit Mark

TASK 1


When an arrow key is pressed, all nodes must move up by 1 unit grid cell distance in corresponding direction.


Let's say the display window is of size (700, 500) such that each column is 35 pixels wide and each row is 25 pixels high.


Let's say the two nodes so far are at (240, 65) and (124, 75)


If the UP key is pressed, the two nodes should move to (240, 40) and (124, 50).


If the DOWN key is pressed (instead of UP key), the two nodes should move to (240, 90) and (124, 100).


If the LEFT key is pressed (instead of UP key), the two nodes should move to (205, 65) and (89, 75).


If the RIGHT key is pressed (instead of UP key), the two nodes should move to (275, 65) and (159, 75).


TASK 2


When you click at any location, the node should be generated at the closest grid intersection point.


The most useful material for this part is compound data.


Distinction Mark

For each node, calculate the sum of distances of that node from every other node.


The node that has the lowest cumulative distance should be coloured red.


The node that has the highest cumulative distance should be coloured blue.


The most useful material for this part is compound data and functions.


(High) Distinction Marks

You can pick-up a node (using mousePressed), drag it and drop it (using mouseReleased) to another point. The node must be dropped at the grid intersection point closest to the where the mouse is released.


Going above-and-beyond

TASK 1


Double-clicking at an already existing node should remove the node.


TASK 2


If none of the lines are intersecting (besides adjacent lines having a common point), the whole shape must be filled with colour code (0, 0, 255, 127) (semi-transparent blue).


TASK 3


Each time you press the ENTER key, a new graph is generated. The old graph should still be displayed on the display window.


Submission

You must submit your complete Processing sketch as a single pde file ass2.pde by the due date.


Constraints

Why do these exist?


You cannot use any extra processing libraries or plugins.

You cannot use any Java libraries or plugins.

You cannot use classes.

You cannot use multiple tabs or multiple files.

You cannot use transformations such as rotate,translate, scale.

You cannot use images.

You must submit a single pde file.

Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes