Advertisement
Guest User

Untitled

a guest
Jul 26th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1.  
  2. //import String;
  3.  
  4. namespace Hello {
  5.  
  6. public struct Vector {
  7.     public float c[4];
  8.  
  9.     public Vector() {
  10.     }
  11.  
  12.     public Vector.from_floats(float pc[4]) {
  13.         c = pc;
  14.     }
  15. }
  16.  
  17. public struct Matrix {
  18.     Vector v[4];
  19.  
  20.     public Matrix(Vector pv[4]) {
  21.         v = pv;
  22.     }
  23.  
  24.     public void mult(Matrix other) {
  25.         // do something
  26.     }
  27. }
  28.  
  29. public class Hello : Object {
  30.  
  31.     private int x;
  32.  
  33.     public Hello(int n = 0) {
  34.         this.x = n;
  35.     }
  36.  
  37.     public int add(int n) {
  38.         this.x += n;
  39.         return this.x;
  40.     }
  41.  
  42. }
  43. }
  44.  
  45.  
  46. int main(string[] args)
  47. {
  48.     var hell = new Hello.Hello(42);
  49.  
  50.     stdout.printf("Hello world %d\n", hell.add(332));
  51.  
  52.     int i = 0;
  53.     foreach (var s in args) {
  54.         stdout.printf("arg #%d '%s'\n", i++, s);
  55.     }
  56.  
  57.     float c[] = { 1,2,3,4};
  58.     var v = Hello.Vector.from_floats(c);
  59.     stdout.printf("v(%g, %g, %g, %g)\n", v.c[0], v.c[1], v.c[2], v.c[3]);
  60.    
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement