notescas.blogg.se

How to make a computer program run automatically on bluej
How to make a computer program run automatically on bluej





how to make a computer program run automatically on bluej

Object can perform (the robot can move, turn left or right, and so on). Still dim? Which direction is the robot facing?), and tasks that the There are two parts to an object,įacts about the thing it represents (Is the blue square lit yet, or Objects, even though they are of the same kind.Īn object represents something, but we, as programmers, need toĭetermine what characteristics of that thing are important to the There might be multipleīricks, or multiple blue squares on a level, and these are all individual

how to make a computer program run automatically on bluej

ThereĪre also blue squares that can be lighted. But there areĪlso bricks that block the robot’s path and that can be stacked. It seems obvious that the robot itself is an object. These may represent the same kind of thing.

how to make a computer program run automatically on bluej

Grid positions–i.e., we always start counting from zero at the origin (topĬoncept or item that is relevant to the problem we are trying toĪ typical program works with several different objects. This means we will always used zero-based indexing when referring to The gridĪbove is 10 by 10 in size, where coordinates run from 0 up to and includingĩ. Represented in our grid and is located at the top left corner. Also notice that the origin (0, 0) is explicitly It is 4 cells horizontally to the right of the origin, and 2 cells verticallyĭown from the origin. So the highlighted cell in the grid shown above is at location (4, 2), since Though it is the opposite of what is typical in studying geometry!). We use a left-handed orientation for our axesīecause that convention is predominant in computer programming contexts (even The y axis points downward in our grid, making thisĪ left-handed Cartesian plane. The origin horizontally, and y (the second coordinate) represents the distanceįrom the origin vertically. We will use a variation of Cartesian coordinates to write any location asĪn (x, y) pair, where x (the first coordinate) represents the distance from







How to make a computer program run automatically on bluej