File: runme.pike

package info (click to toggle)
cmake 2.8.11.1-1~bpo70+1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy-backports
  • size: 37,056 kB
  • sloc: cpp: 157,219; ansic: 137,155; yacc: 3,254; sh: 2,745; xml: 2,483; lex: 1,028; lisp: 215; python: 199; objc: 134; f90: 105; perl: 99; fortran: 93; makefile: 65; tcl: 55; asm: 28; php: 25; ruby: 22; java: 20
file content (53 lines) | stat: -rwxr-xr-x 1,338 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import .example;

int main()
{
    // ----- Object creation -----

    write("Creating some objects:\n");
    Circle c = Circle(10.0);
    write("    Created circle.\n");
    Square s = Square(10.0);
    write("    Created square.\n");

    // ----- Access a static member -----

    write("\nA total of " + Shape_nshapes_get() + " shapes were created\n");

    // ----- Member data access -----

    // Set the location of the object

    c->x_set(20.0);
    c->y_set(30.0);

    s->x_set(-10.0);
    s->y_set(5.0);

    write("\nHere is their current position:\n");
    write("    Circle = (%f, %f)\n", c->x_get(), c->y_get());
    write("    Square = (%f, %f)\n", s->x_get(), s->y_get());

    // ----- Call some methods -----

    write("\nHere are some properties of the shapes:\n");
    write("   The circle:\n");
    write("        area      = %f.\n", c->area());
    write("        perimeter = %f.\n", c->perimeter());
    write("   The square:\n");
    write("        area      = %f.\n", s->area());
    write("        perimeter = %f.\n", s->perimeter());

    write("\nGuess I'll clean up now\n");

    /* See if we can force 's' to be garbage-collected */
    s = 0;

    /* Now we should be down to only 1 shape */
    write("%d shapes remain\n", Shape_nshapes_get());

    /* Done */
    write("Goodbye\n");

    return 0;
}