Tag Archive for main

RectangleTest.java

public class RectangleTest {

public static void main(String[] args) {
Rectangle small = new Rectangle(2.0,3.0);
Rectangle noArgs = new Rectangle();
Rectangle large = new Rectangle(20.4,30.6);
Rectangle notDouble = new Rectangle(4,6);
Rectangle stupid = new Rectangle(3.2,400.1);

System.out.println("Small rectangle: A=" + small.getArea() + " P="+small.getPerimeter());
System.out.println("Default rectangle: A=" + noArgs.getArea() + " P="+noArgs.getPerimeter());
System.out.println("Large rectangle: A=" + large.getArea() + " P="+large.getPerimeter());
System.out.println("Rectangle not written as double: A=" + notDouble.getArea() + " P="+notDouble.getPerimeter());
System.out.println("Stupidly proportioned rectangle: A=" + stupid.getArea() + " P="+stupid.getPerimeter());
}

}

source

New document class

package
{
import flash.display.*;

public class DocumentClass extends MovieClip
{

public function DocumentClass():void
{

}

}

}

source

Python main() functions

import sys
import getopt

class Usage(Exception):
def __init__(self, msg):
self.msg = msg

def main(argv=None):
if argv is None:
argv = sys.argv
try:
try:
opts, args = getopt.getopt(argv[1:], "h", ["help"])
except getopt.error, msg:
raise Usage(msg)
# more code, unchanged
except Usage, err:
print >>sys.stderr, err.msg
print >>sys.stderr, "for help use --help"
return 2

if __name__ == "__main__":
sys.exit(main())

source

Main function

if __name__ == "__main__":
funcion()

source