Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Function Definition
  2. ===================
  3.  
  4. OutputType FunctionName(InputType inputName, IntputType intputNameb, ...) {
  5. statement1;
  6. statement2;
  7. ...
  8. }
  9.  
  10. If statement
  11. ============
  12.  
  13. if (condition) {
  14. statement1;
  15. statement2;
  16. ...
  17. } else {
  18. ...
  19. }
  20.  
  21. int functionAdd(int a, int b) {
  22. return a + b;
  23. ...
  24. ...
  25. ...
  26. }
  27.  
  28.  
  29. Function call
  30. =============
  31. int c = functionAdd(5, 3);
  32.  
  33.  
  34.  
  35. int a = 5;
  36.  
  37. if (a >= 4) {
  38. println("hi");
  39. } else if (a == 5) {
  40. println("bye");
  41. }
  42.  
  43.  
  44. Loops
  45. =====
  46. while (condition) {
  47. ...
  48. statement1;
  49. }
  50.  
  51. int a = 0;
  52.  
  53. while (a < 5) {
  54. println(a);
  55. a = a + 1;
  56. }
  57.  
  58. a = 2
  59. => 0 1 2 3 4
  60.  
  61.  
  62. 1 + 2 + 3 + .... 100
  63.  
  64.  
  65.  
  66.  
  67. PVector postion;
  68.  
  69.  
  70. int = 1, 2, 3, 4, 5, -1, -2
  71. float = 0.2, 0.51234, -1234.24
  72. bool = true/false
  73.  
  74.  
  75. class Dog {
  76. int a;
  77. float b;
  78. AnotherClass c;
  79.  
  80. void sit() {
  81. ...
  82. }
  83.  
  84. void bark() {
  85. ..
  86. }
  87. }
  88.  
  89. ClassName blah = new ...
  90.  
  91. blah.a = ?
  92.  
  93.  
  94. class PVector {
  95. float x;
  96. float y;
  97. float z; // member variables
  98.  
  99. void add(PVector b) { // member functions
  100. x = x + b.x;
  101. y = y + b.y;
  102. z = z + b.z;
  103. }
  104. }
  105.  
  106. PVector a = new PVector(1, 2);
  107. PVector b = new PVector(1, 3);
  108.  
  109. a.add(b);
  110.  
  111. a == 2, 5
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement