Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. Table myData;
  2.  
  3. Soda[] sodas;
  4.  
  5. void setup() {
  6. size(1280, 800);
  7.  
  8. myData = loadTable("my-data.csv", "header");
  9. int numberOfSodas = myData.getRowCount();
  10. sodas = new Soda[numberOfSodas];
  11.  
  12. for(int i=0; i<sodas.length; i++) {
  13. TableRow row = myData.getRow(i);
  14.  
  15. String d = row.getString("DATE");
  16. String t = row.getString("TIME");
  17. String l = row.getString("LOCATION");
  18. int s = row.getInt("SIZE");
  19.  
  20. sodas[i] = new Soda(d, t, l, s, width/numberOfSodas*i, height/4);
  21. }
  22. }
  23.  
  24.  
  25. void draw() {
  26. background(255);
  27.  
  28. for(int i=0; i<sodas.length; i++) {
  29. sodas[i].displaySize();
  30. }
  31. }
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39. class Soda {
  40. // FIELDS
  41. String date;
  42. String time;
  43. String location;
  44. int sizeOfSoda;
  45. float x, y;
  46.  
  47. // CONSTRUCTOR
  48. Soda(String _date, String _time, String _location,
  49. int _sizeOfSoda, float _x, float _y) {
  50. date = _date;
  51. time = _time;
  52. location = _location;
  53. sizeOfSoda = _sizeOfSoda;
  54. x = _x;
  55. y = _y;
  56. }
  57.  
  58. // METHODS
  59. void displaySize() {
  60. ellipse(x, y, sizeOfSoda, sizeOfSoda);
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement