Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Table myData;
- Soda[] sodas;
- void setup() {
- size(1280, 800);
- myData = loadTable("my-data.csv", "header");
- int numberOfSodas = myData.getRowCount();
- sodas = new Soda[numberOfSodas];
- for(int i=0; i<sodas.length; i++) {
- TableRow row = myData.getRow(i);
- String d = row.getString("DATE");
- String t = row.getString("TIME");
- String l = row.getString("LOCATION");
- int s = row.getInt("SIZE");
- sodas[i] = new Soda(d, t, l, s, width/numberOfSodas*i, height/4);
- }
- }
- void draw() {
- background(255);
- for(int i=0; i<sodas.length; i++) {
- sodas[i].displaySize();
- }
- }
- class Soda {
- // FIELDS
- String date;
- String time;
- String location;
- int sizeOfSoda;
- float x, y;
- // CONSTRUCTOR
- Soda(String _date, String _time, String _location,
- int _sizeOfSoda, float _x, float _y) {
- date = _date;
- time = _time;
- location = _location;
- sizeOfSoda = _sizeOfSoda;
- x = _x;
- y = _y;
- }
- // METHODS
- void displaySize() {
- ellipse(x, y, sizeOfSoda, sizeOfSoda);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement