Courses‎ > ‎APCS - Term 1‎ > ‎Konstantinovich‎ > ‎

2019-05-06

posted May 6, 2019, 6:04 AM by Konstantinovich Samuel   [ updated May 6, 2019, 8:17 AM ]
Friday Exam:
    No: Stack/Queue/Deque
    Yes: All sorts, binary search, heaps, trees.

Goal:
    Come up with creative ways to display and move the object.

Free Form Group Lab:
    Groups of 4. One person creates a repo, and adds the others ad collaborators)
    Each Person in the group is responsible for one thing:
        Rock (display only)
        LivingRock (move only)
        Ball (display only)
        Ball (move only)
    Each group should work in pairs, where each member is paired up with someone doing the opposite method (display + move pair up)
    Each pair should help eachother because you are both responsible for understanding drawing and moving!
    If you are done with your method feel free to work on another method with someone!
   

GUIDELINES:
    Do not edit setup/draw
    You MAY edit the class methods, and add extra instance variables to the classes.
    Move:
        Keep the objects on the screen.
    Display:
        Keep the objects size appriximately 50 by 50 but not larger.

PROGRESSION:
Move:
    a) Random Movement to test it out
    b) A simple path (may need some instance variables from here onward)
    c) A more complex path
    d) Randomly choose between several paths.  (you may need a new constructor for this)
    
Display:
    a) A simple shape
    b)Several shapes put together to make something more complex. (may need some instance variables from here onward)
    c) An Image (use the menu sketch -> add file, so you don't have to worry about paths)
    d) Choose randomly: Simple, Complex, or Image  (you may need a new constructor for this)


interface Displayable {
  void display();
}

interface Moveable {
  void move();
}

abstract class Thing implements Displayable {
  float x, y;//Position of the Thing

  Thing(float x, float y) {
    this.x = x;
    this.y = y;
  }
  abstract void display();
}

class Rock extends Thing {
  Rock(float x, float y) {
    super(x, y);
  }

  void display() {
    /* ONE PERSON WRITE THIS */
  }
}

public class LivingRock extends Rock implements Moveable {
  LivingRock(float x, float y) {
    super(x, y);
  }
  void move() {
    /* ONE PERSON WRITE THIS */
  }
}

class Ball extends Thing implements Moveable {
  Ball(float x, float y) {

    super(x, y);
  }

  void display() {
    /* ONE PERSON WRITE THIS */
  }

  void move() {
    /* ONE PERSON WRITE THIS */
  }
}

/*DO NOT EDIT THE REST OF THIS */

ArrayList<Displayable> thingsToDisplay;
ArrayList<Moveable> thingsToMove;

void setup() {
  size(1000, 800);

  thingsToDisplay = new ArrayList<Displayable>();
  thingsToMove = new ArrayList<Moveable>();
  for (int i = 0; i < 10; i++) {
    Ball b = new Ball(50+random(width-100), 50+random(height-100));
    thingsToDisplay.add(b);
    thingsToMove.add(b);
    Rock r = new Rock(50+random(width-100), 50+random(height-100));
    thingsToDisplay.add(r);
  }
  for (int i = 0; i < 3; i++) {
    LivingRock m = new LivingRock(50+random(width-100), 50+random(height-100));
    thingsToDisplay.add(m);
    thingsToMove.add(m);
  }
}
void draw() {
  background(255);

  for (Displayable thing : thingsToDisplay) {
    thing.display();
  }
  for (Moveable thing : thingsToMove) {
    thing.move();
  }
}





Comments