Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Submit onePDE fileforeachprogramming question (total of 3). Submitone PDF filewith your answers to the written questions. Assignments must follow the programming standards document published on the...

1 answer below »
  • Submit onePDE fileforeachprogramming question (total of 3).

  • Submitone PDF filewith your answers to the written questions.

  • Assignments must follow the programming standards document published on the course

    website on UM Learn.

  • After the due date and time assignments may be submitted but will lose 2% of marks per

    hour late or portion thereof. The date and time of the last file submitted controls the mark for the entire assignment.

  • You may submit a question multiple times, but only the most recent version will be marked.

  • These assignments are your chance to learn the material for the exams.Code your

    assignments independently. We use software to compare all submitted assignments to each other, and pursue academic dishonestly vigorously.

    Part 1: Programming

    Hand in threepde files, one each for Questions 1, 2, and 3.Save your program to each question as aseparate filenamedLastnameFirstnameA1QX.pde(where X is 1, 2, or 3 depending on the question number). Submit these files in the Assignment 1 submission folder on UM Learn.

    The marker will run your programs, and may change the canvas size and the value of the constants. It should still work if any constants are changed in a reasonable way.

[Programming Standards are worth 5 marks]

Question 1 – Static Alien [7 marks]

This question requires material from Lecture 3 (Unit 4).

Write a non-active Processing program (containing nosetup()ordraw()functions) which willdraw an alien of your own designon the canvas. Keep it simple and abstract.Do not copythe sample image on the right. Make up a design of your own. Your drawing does not have to be very realistic. Be creative!

- 1 of 5 -

Figure 1: A1Q1 Static Alien

ASSIGNMENT 1
DEPARTMENT AND COURSE NUMBER: COMP 1010 COURSE TITLE: Introductory Computer Science 1 TERM: Summer 2020

The rules to draw your alien are:

  • The alien must be drawn using 6 to12 shapes (lines, ellipses, rectangles, or other

    shapes). The sample shown here uses 11 shapes: 8 ellipses, 2 rectangles, and 1 line.

  • It must contain at least one line, at least one ellipse or circle, and at least one square,

    rectangle, triangle, or quadrilateral (quad).

  • It should contain several different colours. Choose a dark colour for the background.

  • It should usestrokeWeight()to adjust the thickness of the line(s).

  • Don’t make it too complex. Stick to the limit of 12 shapes. That will make the remaining

    questions easier.

  • In this question, your object should at least half of the canvas.

    You must follow the rules below in your program:

  • At the top of your program, define threeconstants:

    1. SIZE– which will control the size of your alien. This can be the width, height, or any other suitable dimension that you like.

    2. X_CENTRE– controls the location of your alien on the x-axis.

    3. Y_CENTRE– controls the location of your alien on the y-axis.

  • The coordinates(X_CENTRE, Y_CENTRE)should be roughly the middle of your alien.

  • Define suitable constants forall other dimensions and coordinatesneeded to draw

    the alien, such as heights, widths, diameters, stroke weights, and the coordinates of

    corners or the endpoints of lines.

  • All of these constants must be calculated from some combination ofSIZE,X_CENTRE, andY_CENTRE,or from constants that depend on these)!
    For example:

    // good! multiplying by 2 and diving by 3 is just a ratio

    final int HEAD_HEIGHT = 2*SIZE/3;

    // good! can use any previously defined constants

    final int ANTENNA_START = Y_CENTRE – HEAD_HEIGHT/2;

    // bad! 100 is a magic number. If HEAD_HEIGHT changes,
    // EYE_SIZE won’t scale
    final int EYE_SIZE = HEAD_HEIGHT – 100;
    // bad! not calculated from previous constants (magic number!)final int EYEBALL_SIZE = 20;

  • You do not need to use constants to define colours.

  • Use the constants you have defined to draw the object. You should be able to change

    the size of the canvas, orSIZE,X_CENTRE, orY_CENTRE, and the object should still be drawn correctly at any size and in any location.

  • You can use some arithmetic and small constants as ratios in your drawing commands. For example, a formula likeX_CENTRE + SIZE/2could be used for an X coordinate when drawing a circle, instead of creating a new constant to store that coordinate. This will reduce the number of constants needed.

- 2 of 5 -

ASSIGNMENT 1
DEPARTMENT AND COURSE NUMBER: COMP 1010 COURSE TITLE: Introductory Computer Science 1 TERM: Summer 2020

Question 2 – Active Alien [9 marks]

This question requires material from Lecture 4 (Units 5 & 6).

Convert your program from Question 1 into an Active Processing program, with the mouse controlling both the size and position of your object.

  • Save a copy of your original Question 1 program. You must hand in the original static version, as well as this modified active version. Rename this one so that it ends with “A1Q2”.

  • All of theconstantsdefined in Question 1 must now be changed intovariablessince they will now be controlled by the mouse. [The Find... command in the Edit menu contains a Replace All button which will be very useful to change names.]

  • Declare and initialize two new integer global constants, giving them reasonable values:1. MIN_SIZE

    2. MAX_SIZE

  • Create the usualsetup()anddraw()functions.

  • Write asetSizeAndLocation()function, which will use the mouse position to set the

    three variables that control the size and position of your object.

oThecentreofyourobjectshouldalwaysbeatthemouseposition.
oThesizeofyourobjectshouldbecontrolledbymouseX.Theobjectshouldhave

a size ofMIN_SIZEwhen the mouse is at the left edge of the canvas, andMAX_SIZEwhen the mouse is at the right edge of the canvas, and it should change size smoothly in between.

  • Write acalcDimensions()function which will calculate all of the variables that control the drawing of the object (the ones that used to be constants but are now variables). The code should be almost the same as the constant declarations you used in Question 1 (except for the names of the variables).

  • Write adrawAlien()function that will draw your alien. All of the drawing code from Q1 should be copied into this function. You shouldn’t have to change any of this code, other than the names of the variables.

  • Call these functions in the appropriate order fromsetup()anddraw().

  • Your object should follow the mouse around the canvas, and grow or shrink. It should

    work for any size canvas, and any reasonable values ofMIN_SIZEandMAX_SIZE.

Figure 2: A1Q2 Alien is small when the mouse is at the left side of the canvas, and big when the mouse is at the right side of the canvas.

- 3 of 5 -

ASSIGNMENT 1
DEPARTMENT AND COURSE NUMBER: COMP 1010 COURSE TITLE: Introductory Computer Science 1 TERM: Summer 2020

Question 3 – Hello Moon [6 marks]

Convert your program from Question 2 so that your alien flies down from the top of the canvas to land on the moon all by itself in a straight vertical line, without being constantly controlled by the mouse.This question requires material from Lecture 4 (Units 5 & 6).

Make the following changes and additions to your Question 2 program.

  • Save a copy of your original Q2 program. You must hand in that

    version, as well as this new version. Rename this one so that it

    ends with “A1Q3”.

  • Define the following new global variables and constants at the top

    of your program:

    1. MOON_HEIGHT– choose a number between 30 and 100

      pixels for the height of the moon.

    2. Y_START– choose a negative number, so the alien starts

      higher than the top of the canvas.

    3. SPEED_FACTOR– choose a positive number. This

      constant will control the speed of the alien.

    4. xPosition– don’t assign a value to this yet. This

      variable will control the x-coordinate of the alien’s flight

      path to the moon.

    5. yEnd– don’t assign a value to this yet. This variable will

      control where the alien stops moving on the y-axis (so it can land on the moon).

  • Modify thesetup()function to assign initial values toxCentre,yCentre,size,xPosition, andyEndso that they have the appropriate values to start the animation:

oThealienshouldmoveinastraightverticallinefromthepoint(xPosition,Y_START)to the point(xPosition,yEnd).

oxPositionshould be the middle of the canvas, width-wise.
oyEndshould be chosen such that the alien stops moving when it reaches the

moon (NOT the bottom of the canvas).
oThealien’ssizeshouldstartatMIN_SIZEandendatMAX_SIZE.oYoumaywishtomakeyourcanvastallerforQ3.

  • Write a new function calleddrawMoon()which draws a rectangle ofMOON_HEIGHTalong the bottom of the canvas. Choose a colour for the moon!

    oYoumaywanttousethefunctionnoStroke()forthemoon(andthebottom shape of your alien) if you want the alien to land exactly on the moon.

  • Modify thedraw()function to calldrawMoon()

  • Modify thesetSizeAndLocation()function so that the alien moves and changes

    size as defined above (Hint: onlyyCentreandsizeneed to change each frame)

oUseSPEED_FACTORtocontrolhowfastthealienmovesandchangessize.Each

frame, the size and vertical location of the alien should change just a little bit.oYoumaywishtousethebuilt-inmin()functionsothatyCentreandsize

don’t increase forever.

  • Define the specialvoid mouseClicked()function, which Processing will run

    automatically every time the mouse is clicked anywhere in the canvas. Do not call this function yourself! When the mouse is clicked, the alien should reset to the starting position and size, and then, in the frames that follow, land on the moon again.

  • You should not have to make any changes at all to thecalcDimensions()ordrawAlien()functions.

- 4 of 5 -

Figure 3: A1Q3 Alien lands on the moon.

ASSIGNMENT 1
DEPARTMENT AND COURSE NUMBER: COMP 1010 COURSE TITLE: Introductory Computer Science 1 TERM: Summer 2020

Part 2: Written Questions

Save your answers to these questions as aPDF documentnamedLastnameFirstnameA1.pdfand submit this file in the Assignment 1 submission folder on UM Learn.

Question 4 – Exploring Beyond Earth [2 marks]

Not only do we have lots of computers on Earth, but humans have also put computers on other planets (like Mars) and sent computers on probes to observe the far reaches of our solar system. These well-travelled machines need a way to communicate with scientists and engineers back at home, and for NASA that is the Deep Space Network (DSN).

(a) What are the names of the four rovers that NASA has already sent to Mars?

(b) What is the name of the rover that NASA is planning to send to Mars this year, and when is its launch window?

Question 5 – Distributed Computing [1 mark]

Many people are interested in finding out what is beyond our planet, but not everyone has lots of computing power like NASA. One solution is to break up the large computing problem into smaller pieces, and give each piece to a different computer to solve. This is calleddistributed computing. Using distributed computing, people can volunteer the idle time from their personal computers to projects that require lots of computations – effectively “crowd-sourcing” computing power.

What is the name of one of the three major distributed computing projects that studies interstellar space phenomena?

Answered Same Day Jun 20, 2021

Solution

Pratik answered on Jun 21 2021
158 Votes
int y=0;
int xcentre=400;
int ycentre;
float size=250;
void setup(){
size(800,800);
ackground(0);
ycentre=0;
}
void drawMoon(){
fill(200);
ect(0,770,width,30);
}
void mouseClicked(){
ycentre=0;
}
void drawAlien(){
stroke(0);
fill(180,270,200);
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here