java代写| oop代写 | 代写assignment | CS代写 – COMP 1010 COURSE


java代写| oop代写 | 代写assignment – 本题是一个利用java进行练习的代做, 对java的编程流程进行训练解析, 涵盖了oop等方面, 该题目是值得借鉴的assignment代写的题目

ass代做 assignment代写 代写assignment


assignment 1


  • Name your sketches using your name, the assignment number, and the question number, exactly as in this example: LastnameFirstnameA 1 Q 1.
  • Your programs must run upon download to receive any marks.
  • Submit one PDE file for each question.
  • Assignments must follow the programming standards document published on the course website on UMLearn.
  • After the due date and time assignments may be submitted but will lose 2% of marks per hour late or portion thereof.
  • 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.


Q1: An Animal

You should be able to do this question after Week 2 in the course.
Write a non-active Processing program (containing no setup() or draw()
functions) which will draw some sort of animal in the canvas. It can be anything
you like: a tiger, a dog, a mouse, any animal. Be creative. The rules are:
  • It must contain from 6 to 16 shapes (lines, ellipses, rectangles, or other shapes). The sample mouse shown here uses 11 shapes (2 rectangles, 5 ellipses, and 4 lines).
  • 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.
  • It can be a very abstract animal, like the one shown. You dont have to be a great artist.
  • Dont make it too complex. Stick to the limit of 16 shapes. That will make the remaining questions easier.
  • You must use a 500 x 500 canvas for this question.
  • The animal must fill the canvas, either horizontally (as the mouse does), or vertically.
  • It should be roughly centred in the window. In Questions 2 and 3, your animal will grow, shrink, and move. As soon as any program is finished, you usually have to start making changes to it, and that will happen with this program, too. To make that easier to do, you must do the following things:
  • All X coordinates, Y coordinates, heights, widths, and colours, must be defined by constants. You will probably need at least 10 , and perhaps as many as 30 if you choose to do a very complex animal. There is no limit on the number of constants you use.
  • The X and Y coordinates should be specified relative to the centre of the window. This will make the following questions much easier. Heights and widths will be in pixels. For example, this constant is used to define part of the example mouse. final int BODY_WIDTH=width/2; //total width of body section
  • All of your drawing commands should use your constants, the built-in height and width variables, and perhaps simple numbers like 1 or 2. No other numbers. For example, the ellipse that forms the main body of the mouse was drawn with the statement below. ellipse(width/2, height/2, width/2 , height/2 – bodyWidth);
  • If some calculation is needed many times in many statements, do it only once and store the result in a variable. Then use that variable many times. For example, a better version of the above statement would be the one below, where MOUSE_BODY_WIDTH and MOUSE_BODY_X were pre-calculated, since those values were needed many times to draw the entire animal. (Hint: It would be a really good idea to pre-calculate the coordinates of the centre of the canvas.) ellipse(MOUSE_BODY_X, MOUSE_BODY_Y, MOUSE_BODY_WIDTH, MOUSE_BODY_HEIGHT);


Q2: A Moving Animal

This question requires material from Week 3. Convert your
program from Question 1 into an Active Processing program,
with the mouse controlling both the size and position of the
animal. Make the following changes and additions to your
Question 1 program.
  1. 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.
  2. Add five variables to your program, which control the animals size and position. There should be an X coordinate, a Y coordinate, size, and a MIN_SIZE and MAX_SIZE value. The X and Y coordinates should specify the position of the approximate centre of the animal (the same spot that used to be at the centre of the canvas, but could now be anywhere). The size variables should give the minimum size the animal should reach when near the top of the canvas and the maximum size the animal should reach when nearing the bottom.
  3. Create the usual setup() and draw() functions. Create a drawAnimal() function (or call it drawCat () or drawMouse() , or whatever name is appropriate for you). Create a moveAnimal() function (or use a similar name).
  4. Move all your existing code from Q 1 into the appropriate place in these new functions. All of the code that dr aws your animal should go into the drawAnimal() function, not into the draw() function directly. The functions should call each other as needed.
  5. The moveAnimal() function should use the mouse position to set the X, and Y, and size values for your animal (the ones described in point 2). The X and Y values should exactly match the mouse position. The size variable can be calculated by using the MIN_SIZE, MAX_SIZE and mouseY such that, when the mouse is at the top of the screen, the animal is at its MIN_SIZE, and when its at the bottom, it will be at its MAX_SIZE. This will be a very short function.
  6. Now you need to change all of the commands that draw your animal, so that they take into account its position and size. If you took the hint in Question 1, controlling the position should be very easy. To control the size, you will have to scale almost all of the constants from Question 1, using the animals current size, and its original size (500). For example, BODY_HEIGHT used to control the height of the example animals body. Now it must be BODY_HEIGHTanimalSize/ORIGINAL_SIZE*.
  7. When using int values, be careful. BODY_HEIGHTanimalSize/ORIGINAL_SIZE* works but animalSize/ORIGINAL_SIZEBODY_HEIGHT* will usually just give you 0. Always do the multiplication first. And dont try to store animalSize/ORIGINAL_SIZE in an int variable, as nice as that would be. Youll just get 0.
  8. Now change the size of the canvas to 1000 by 1000 pixels, or to any other size. If youve written your program well, everything should still work, with no modification. Did it?
  9. Optional: If you want to use float , from Week 4 material, go ahead. It would make things somewhat simpler. But its not required.


Q3: A Self-propelled Animal

Convert your program from Question 2 so that your animal will move across the canvas, and
change size, all by itself. Heres how it should work: When you click the mouse in the canvas,
your animal should slowly and smoothly move to that position (or close to it).
Make the following changes and additions to your Question 2 program.
  1. Save a copy of your original Question 2 program. You must hand in that version, as well as this new version. Rename this one so that it ends with A1Q3.
  2. Add a mouseClicked() function ( void mouseClicked() ). This is a special function, like setup() and draw() , which is automatically called every time there is a mouse click in the canvas. The mouseX and mouseY variables give the location of the click. The location of the last mouse click should be stored in appropriately-named state variables.
  3. Change your moveAnimal() function (or whatever you have chosen to name it) so that your animal will now move slowly and steadily toward the location of the most recent mouse click. Use a constant to control your animals speed. In each frame, it should move 1/ N th of the way from its current position to the location of the mouse click. (But dont call the constant N use a better name.) Note: When the animal gets close to the desired location, it will reach a point where its position will change by less than 1 pixel per frame. Since you are using int variables, you will get a change of 0 pixels per frame, and your animal will stop a bit too soon. This is OK. (If you wish to use float variables to solve this problem, go ahead.)
  4. The size of your animal should depend on the Y coordinate of its current location in the canvas, not on the location of the last mouse click, or on the current position of the mouse. Its size should change slowly and smoothly, just as its position does.