1
Fork 0

Compilation phase complete.

master
Joshua Potter 2014-04-15 15:31:09 -04:00
parent 5580416065
commit 65e5c05c70
153 changed files with 0 additions and 1471 deletions

View File

@ -1,73 +0,0 @@
package tester;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
/* Automated regression tester for Checkpoint 3 tests
* Created by Max Beckman-Harned
* Put your tests in "tests/pa3_tests" folder in your Eclipse workspace directory
* If you preface your error messages / exceptions with ERROR or *** then they will be displayed if they appear during processing
*/
public class Checkpoint3 {
public static void main(String[] args) throws IOException, InterruptedException {
File testDir = new File(System.getProperty("java.class.path")
+ "/../tests/pa3_tests");
int failures = 0;
for (File x : testDir.listFiles()) {
if (x.getName().endsWith("out") || x.getName().startsWith(".") || x.getName().endsWith("mJAM") || x.getName().endsWith("asm"))
continue;
int returnCode = runTest(x);
if (x.getName().indexOf("pass") != -1) {
if (returnCode == 0) {
System.out.println(x.getName() + " processed successfully!");
}
else {
failures++;
System.err.println(x.getName()
+ " failed to be processed!");
}
} else {
if (returnCode == 4)
System.out.println(x.getName() + " failed successfully!");
else {
System.err.println(x.getName() + " did not fail properly!");
failures++;
}
}
}
System.out.println(failures + " failures in all.");
}
private static int runTest(File x) throws IOException, InterruptedException {
ProcessBuilder pb = new ProcessBuilder("java", "miniJava.Compiler", x.getPath()).directory(new File(System.getProperty("java.class.path")));
pb.redirectErrorStream(true);
Process p = pb.start();
processStream(p.getInputStream());
p.waitFor();
int exitValue = p.exitValue();
return exitValue;
}
public static void processStream(InputStream stream) {
Scanner scan = new Scanner(stream);
while (scan.hasNextLine()) {
String line = scan.nextLine();
if (line.startsWith("*** "))
System.out.println(line);
if (line.startsWith("ERROR")) {
System.out.println(line);
//while(scan.hasNext())
//System.out.println(scan.next());
}
}
scan.close();
}
}

View File

@ -1,13 +0,0 @@
/*** F02 is invalid qualified reference
* COMP 520
* Identification
*/
class fail61 {
public static void main(String[] args) {
F02 c = F02;
}
}
class F02 {
public int x;
}

View File

@ -1,11 +0,0 @@
/*** class fail01 has multiple declarations
* COMP 520
* Identification
*/
class fail01 {
public static void main(String[] args) {}
}
class fail01 {
// duplicate class
}

View File

@ -1,13 +0,0 @@
/*** undeclared class "Missing" in line 11
* COMP 520
* Identification
*/
class Fail02 {
public static void main(String[] args) {}
int x;
Missing c;
}

View File

@ -1,11 +0,0 @@
/*** duplicate field names in same class
* COMP 520
* Identification
*/
class fail06 {
public static void main(String[] args) {}
public int x;
private int x;
}

View File

@ -1,12 +0,0 @@
/*** duplicate method names in same class
* COMP 520
* Identification
*/
class fail07 {
public static void main(String[] args) {}
}
class F07 {
public void foo() {}
private void foo() {}
}

View File

@ -1,12 +0,0 @@
/*** duplicate field and member name foo in the same class
* COMP 520
* Identification
*/
class fail08 {
public static void main(String[] args) {}
}
class F08 {
public int foo;
private void foo() {}
}

View File

@ -1,13 +0,0 @@
/*** duplicate declaration of class "System" in line 11 (cannot hide predefined classes)
* COMP 520
* Identification
*/
class Fail09 {
public static void main(String[] args) {
System.out.println(5);
}
}
class System {
public int x;
}

View File

@ -1,15 +0,0 @@
/*** can't redeclare a parameter as a local var
* COMP 520
* Identification
*/
class fail10 {
public static void main(String[] args) {}
public void foo(int parm) {
int x = 0;
{
int parm = 4;
}
}
}

View File

@ -1,14 +0,0 @@
/*** can't redeclare local var in nested block
* COMP 520
* Identification
*/
class fail11 {
public static void main(String[] args) {}
public void foo(int parm) {
int x = 0;
{
int x = 4;
}
}
}

View File

@ -1,10 +0,0 @@
/*** can't declare a parameter with type void
* COMP 520
* Identification
*/
class fail12 {
public static void main(String[] args) {}
public void foo(void parm) {}
}

View File

@ -1,14 +0,0 @@
/*** variable declaration as solitary statement in an arm of a conditional
* COMP 520
* Identification
*/
class fail13 {
public static void main(String[] args) {
int x = 0;
if (3 > 4)
x = 1;
else
int y = 2;
}
}

View File

@ -1,15 +0,0 @@
/*** var decl can not reference id in initializing expression
* COMP 520
* Identification
*/
class fail14 {
public static void main(String[] args) {}
int x;
int y;
public void foo() {
int x = y + x;
}
}

View File

@ -1,14 +0,0 @@
/*** undeclared identifier "z" referenced in line 11
* COMP 520
* Identification
*/
class fail15 {
public static void main(String[] args) {}
int y;
public void foo() {
int x = y + z;
}
}

View File

@ -1,11 +0,0 @@
/*** type of parameter x is not a classtype
* COMP 520
* Identification
*/
class fail16 {
public static void main(String[] args) {}
public void foo(main x) {
}
}

View File

@ -1,10 +0,0 @@
/*** duplicate declaration for parameter x
* COMP 520
* Identification
*/
class fail17 {
public static void main(String[] args) {}
public void foo(int x, int x) {}
}

View File

@ -1,12 +0,0 @@
/*** variable declaration as solitary statement in the body of the while construct
* COMP 520
* Identification
*/
class fail19 {
public static void main(String[] args) {
int x = 0;
while (3 > 4)
int y = 2;
}
}

View File

@ -1,9 +0,0 @@
/*** no "main" method found
* COMP 520
* Identification
*/
class fail20 {
public int foo(int x) {
return x;
}
}

View File

@ -1,11 +0,0 @@
/*** duplicate declaration of "main" method
* COMP 520
* Identification
*/
class fail21 {
public static void main(String [] args) {}
}
class F20 {
public static void main(String [] args) {}
}

View File

@ -1,7 +0,0 @@
/*** no suitable "main" method found (single arg)
* COMP 520
* Identification
*/
class fail22 {
public static void main(String [] args, int extra) {}
}

View File

@ -1,7 +0,0 @@
/*** no suitable "main" method found (must have "public" visibility)
* COMP 520
* Identification
*/
class fail23 {
private static void main(String [] args) {}
}

View File

@ -1,10 +0,0 @@
/*** no "main" method found (incorrect argument type)
* COMP 520
* Identification
*/
class fail24 {
public static void main(Other [] args) {}
}
class Other {
}

View File

@ -1,7 +0,0 @@
/*** no "main" method found (must have static access)
* COMP 520
* Identification
*/
class fail25 {
public void main(String [] args) {}
}

View File

@ -1,9 +0,0 @@
/*** no error in contextual analysis, but should exit(4)
* COMP 520
* Parse error
*/
class fail26 {
public static void main(String [] args) {
return;
}
}

View File

@ -1,9 +0,0 @@
/*** no "main" method found (with "void" return type)
* COMP 520
* Type checking
*/
class fail27 {
public static int main(String [] args) {
return 3;
}
}

View File

@ -1,9 +0,0 @@
/*** type error for first argument to "println" method in line 7
* COMP 520
* Type checking
*/
class fail28 {
public static void main(String [] args) {
System.out.println(args[0]);
}
}

View File

@ -1,9 +0,0 @@
/*** incorrect operand type for +
* COMP 520
* Type Checking
*/
class fail30 {
public static void main(String[] args) {
int a = 1 + (2 < 3);
}
}

View File

@ -1,14 +0,0 @@
/*** type void in an expression
* COMP 520
* Type Checking
*/
class fail31 {
public static void main(String[] args) {
fail31 f = new fail31();
int x = 1 + f.noresult();
}
void noresult() {}
}

View File

@ -1,14 +0,0 @@
/*** return value does not agree with declared return type of function
* COMP 520
* Type Checking
*/
class fail32 {
public static void main(String[] args) {
fail32 f = new fail32();
f.noresult();
}
public void noresult() {
return 10;
}
}

View File

@ -1,9 +0,0 @@
/*** can't assign to boolean literal
* COMP 520
* Identification
*/
class fail33 {
public static void main(String[] args) {
true = false;
}
}

View File

@ -1,15 +0,0 @@
/*** can't assign to method name "f" in "b.f" on line 8
* COMP 520
* Identification
*/
class fail34 {
public static void main(String[] args) {
B b = new B();
b.f = 5;
}
}
class B {
public int f() {return 3;}
}

View File

@ -1,17 +0,0 @@
/*** type error on equality: comparison between different types
* COMP 520
* Type Checking
*/
class fail35 {
public static void main(String[] args) {
boolean c = (new A() == new B());
}
}
class A {
int y;
}
class B {
int x;
}

View File

@ -1,16 +0,0 @@
/*** non void function must return a result
* COMP 520
* Type checking
*/
class T36 {
public static void main(String [] args) {
T36 h = new T36();
int x = h.foo();
}
// missing return stmt
public int foo() {
int y = 3;
}
}

View File

@ -1,11 +0,0 @@
/*** non-boolean result type in expr of conditional
* COMP 520
* Type checking
*/
class bob {
public static void main(String [] args) {
int x = 3;
if (x)
x = x + 1;
}
}

View File

@ -1,9 +0,0 @@
/*** incompatible types in equality
* COMP 520
* Type checking
*/
class bob {
public static void main(String [] args) {
boolean b = 15 + 7 == true;
}
}

View File

@ -1,12 +0,0 @@
/*** incompatible types in assignment
* COMP 520
* Type checking
*/
class C1 {
public static void main(String [] args) {
C2 c = new C1();
}
}
class C2 {
}

View File

@ -1,12 +0,0 @@
/*** multiple error detection: incompatible types on lines 7 and 8
* COMP 520
* Type checking
*/
class fail39 {
public static void main(String [] args) {
int x = 3 > 4;
boolean b = 2 + 3;
}
}

View File

@ -1,16 +0,0 @@
/*** incorrect type result returned from function
* COMP 520
* Type checking
*/
class T41 {
public static void main(String [] args) {
T41 h = new T41();
int x = h.foo();
}
// return type not compatible with declared return type
public int foo() {
return 3 < 4;
}
}

View File

@ -1,11 +0,0 @@
/*** limit cascaded errors: should report single type error
* COMP 520
* Identification
*/
class Fail42 {
public static void main(String[] args) {
int x = 2 + (3 + (4 + (5 + (1 != 0))));
}
}

View File

@ -1,21 +0,0 @@
/*** incorrect type for argument of f(int)
* COMP 520
* Type checking
*/
class Fail43 {
public static void main(String[] args) {
A a = new A();
a.g();
}
}
class A{
public void g() {
int x = f(g());
}
public int f(int x) {
return 5;
}
}

View File

@ -1,9 +0,0 @@
/*** cannot declare field with type void
* COMP 520
* Type checking
*/
class fail45 {
public static void main(String[] args) { }
void x; // incorrect type for a field
}

View File

@ -1,12 +0,0 @@
/*** < not defined for boolean type
* COMP 520
* Type checking
*/
class fail46 {
public static void main(String[] args) {
int x = 1;
if (true < false)
x = 2;
}
}

View File

@ -1,11 +0,0 @@
/*** can't access non-static fields from within a static method
* COMP 520
* Identification
*/
class fail52 {
public static void main(String[] args) {
int y = x + 3;
}
public int x;
}

View File

@ -1,13 +0,0 @@
/*** can't access non-static method from within a static method
* COMP 520
* Identification
*/
class fail53 {
public static void main(String[] args) {
int y = f() + 3;
}
public int f() {
return 7;
}
}

View File

@ -1,13 +0,0 @@
/*** can't access non-static field y from within a static context in ref C.y
* COMP 520
* Identification
*/
class C {
public static void main(String[] args) { }
public void f() {
int x = C.y;
}
public int y;
}

View File

@ -1,11 +0,0 @@
/*** non-static method f() can not be referenced from a static context in ref D.f()
* COMP 520
* Identification
*/
class D {
public static void main(String[] args) { }
public int f(){
return D.f();
}
}

View File

@ -1,13 +0,0 @@
/*** F02 is invalid qualified reference
* COMP 520
* Identification
*/
class fail61 {
public static void main(String[] args) {
F02 c = F02;
}
}
class F02 {
public int x;
}

View File

@ -1,15 +0,0 @@
/*** no access to private field from outside class
* COMP 520
* Identification
*/
class fail62 {
public static void main(String[] args) {
F02 c = new F02();
int y = c.x;
}
}
class F02 {
public F02 next;
private int x;
}

View File

@ -1,16 +0,0 @@
/*** no access through a private field from outside the class
* COMP 520
* Identification
*/
class fail63 {
public static void main(String[] args) {
F03 c = new F03();
c.next.also.x = 3;
}
}
class F03 {
public F03 next;
private F03 also;
public int x;
}

View File

@ -1,15 +0,0 @@
/*** no access to private method from outside the class
* COMP 520
* Identification
*/
class fail64 {
public static void main(String[] args) {
F04 c = new F04();
c.foo();
}
}
class F04 {
public F04 next;
private void foo() {}
}

View File

@ -1,15 +0,0 @@
/*** no access to a private method from outside class via qualified ref
* COMP 520
* Identification
*/
class fail65 {
public static void main(String[] args) {
F05 c = new F05();
c.next.next.foo();
}
}
class F05 {
public F05 next;
private void foo() {}
}

View File

@ -1,15 +0,0 @@
/*** no access through a method in qualified reference
* COMP 520
* Identification
*/
class fail66 {
public static void main(String[] args) {
F05 c = new F05();
c = c.foo.next;
}
}
class F05 {
public F05 next;
public F05 foo() {return this;}
}

View File

@ -1,15 +0,0 @@
/*** no dereference from non-class types
* COMP 520
* Identification
*/
class F67 {
public static void main(String[] args) {
F05 c = new F05();
c = c.foo.next;
}
}
class F05 {
public F05 next;
public int foo;
}

View File

@ -1,13 +0,0 @@
/*** no dereference from non-class types
* COMP 520
* Identification
*/
class fail68 {
public static void main(String[] args) {
int c = 4;
c = c.foo;
}
int foo;
}

View File

@ -1,7 +0,0 @@
/**
* COMP 520
* Identification
*/
class pass01 {
public static void main(String[] args) {}
}

View File

@ -1,14 +0,0 @@
/**
* COMP 520
* Identification
*/
class pass02 {
public static void main(String[] args) {}
A02 a;
}
class A02 {
int x;
}

View File

@ -1,21 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass03 {
public static void main(String[] args) {}
public void f() {
C = 5;
}
int C; // hides class C at member level
}
class C {
int x;
}

View File

@ -1,13 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass04 {
public static void main(String[] args) {}
public void foo(Pass04 x) {
int Pass04 = 3;
Pass04 y = x; /* not hidden */
}
}

View File

@ -1,9 +0,0 @@
/**
* COMP 520
* Identification
*/
class pass06 {
public static void main(String[] args) {
System.out.println(3);
}
}

View File

@ -1,14 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass07 {
public static void main(String[] args) {
Pass07 p07 = new Pass07();
p07.next = p07;
p07.next.next.x = 3;
}
public Pass07 next;
private int x;
}

View File

@ -1,20 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass08 {
public static void main(String[] args) {
A08 a08 = new A08();
Pass08 p08 = new Pass08();
p08.a = a08;
a08.p = p08;
int y = p08.a.p.a.x;
}
public A08 a;
}
class A08 {
public Pass08 p;
public int x;
}

View File

@ -1,17 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass09 {
public static void main(String[] args) {
F03 c = new F03();
c.next.mynext.x = 3;
}
private F03 mynext; // normally no access, but ok if dereferenced within Pass09
}
class F03 {
public Pass09 next;
public int x;
}

View File

@ -1,18 +0,0 @@
/**
* COMP 520
* Identification
*/
class pass10 {
public static void main(String[] args) {}
int C; // does not hide class C
C c; // OK
}
class C {
int x;
}

View File

@ -1,10 +0,0 @@
/*
* COMP 520
* Identification
*/
class A {
public static void main(String[] args) {}
public void foo(A A) {} // A may have both definitions in the same scope
}

View File

@ -1,11 +0,0 @@
/*
* COMP 520
* Identification
*/
class fail21 {
public static void main(String [] args) {}
}
class F20 {
public void main(String [] args) {} // not a main method (not static)
}

View File

@ -1,12 +0,0 @@
/*
* COMP 520
* Identification
*/
class fail50 {
public static void main(String[] args) {}
// permit static members other than main
public static int foo(int parm) {
return 50;
}
}

View File

@ -1,10 +0,0 @@
/*
* COMP 520
* Identification
*/
class fail51 {
public static void main(String[] args) {}
// permit static fields
public static int x;
}

View File

@ -1,11 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass15 {
public static void main(String[] args) {
int x = 3;
{int y = 4; }
{int z = 10; int y = 5; }
}
}

View File

@ -1,15 +0,0 @@
/**
* COMP 520
* Type Checking
*/
class Pass16 {
public static void main(String[] args) {
Pass16 a = new Pass16();
boolean c = a.b() && a.p() == 5;
}
int p() {return 5;}
boolean b() {return true == false;}
}

View File

@ -1,13 +0,0 @@
/***
* COMP 520
* Identification - static method invocation
*/
class fail50 {
public static void main(String[] args) {
int x = foo(20);
}
public static int foo(int parm) {
return 50;
}
}

View File

@ -1,19 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass21 {
public static void main(String[] args) {
int A11 = 3;
}
public A11 a;
private int foo(int A11) { // ok
return A11;
}
}
class A11 {
public int x;
}

View File

@ -1,11 +0,0 @@
/***
* COMP 520
* Identification - static member access
*/
class fail51 {
public static void main(String[] args) {
int z = x;
}
public static int x;
}

View File

@ -1,16 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass23 {
public static void main(String[] args) {
Pass23 p = new Pass23();
int x = p.p() + p.x;
}
public int x;
public int p() {
return 3;
}
}

View File

@ -1,20 +0,0 @@
/**
* COMP 520
* Identification
*/
class Pass25 {
private void Foo() {
Foiled.back.mine = 3;
}
public static int mine;
}
class Foiled {
public static void main(String[] args) {}
static Pass25 back;
}

View File

@ -1,13 +0,0 @@
/**
* COMP 520
* simple int value and printing
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
tstvar = 1;
System.out.println (tstvar);
}
}

View File

@ -1,15 +0,0 @@
/**
* COMP 520
* int arithmetic
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
tstvar = 1;
tstvar = 2 * tstvar + tstvar - 1;
System.out.println (tstvar);
}
}

View File

@ -1,18 +0,0 @@
/**
* COMP 520
* conditionals
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
tstvar = 2;
if (tstvar == 2)
tstvar = 3;
else
tstvar = -1;
System.out.println(tstvar);
}
}

View File

@ -1,20 +0,0 @@
/**
* COMP 520
* repetitive statement
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
tstvar = 3;
int i = 0;
while (i < 4) {
i = i + 1;
tstvar = i;
}
System.out.println(tstvar);
}
}

View File

@ -1,24 +0,0 @@
/**
* COMP 520
* Object creation and field update
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
FirstClass f = new FirstClass ();
tstvar = 5 + f.n;
System.out.println(tstvar);
}
}
class FirstClass
{
int n;
}

View File

@ -1,36 +0,0 @@
/**
* COMP 520
* Object creation and update
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
FirstClass f = new FirstClass ();
f.s = new SecondClass ();
// write and then read;
f.s.n = 6;
tstvar = f.s.n;
System.out.println(tstvar);
}
}
class FirstClass
{
int n;
SecondClass s;
}
class SecondClass
{
int n;
FirstClass f;
}

View File

@ -1,38 +0,0 @@
/**
* COMP 520
* Qualified references
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
tstvar = 6;
FirstClass f = new FirstClass ();
f.s = new SecondClass ();
// write and then read;
f.s.f = f;
f.s.f.n = tstvar + 1;
tstvar = f.n;
System.out.println(tstvar);
}
}
class FirstClass
{
int n;
SecondClass s;
}
class SecondClass
{
int n;
FirstClass f;
}

View File

@ -1,15 +0,0 @@
/**
* COMP 520
* Array creation
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
int aa_length = 4;
int [] aa = new int [aa_length];
tstvar = aa_length * 2;
System.out.println(tstvar);
}
}

View File

@ -1,24 +0,0 @@
/**
* COMP 520
* Array update
*/
class MainClass {
public static void main (String [] args) {
int tstvar = 0;
int aa_length = 4;
int [] aa = new int [aa_length];
int i = 0;
i = 1;
aa[0] = i;
while (i < aa_length) {
aa[i] = aa[i-1] + i;
i = i + 1;
}
tstvar = aa[3] + 2;
System.out.println(tstvar);
}
}

View File

@ -1,22 +0,0 @@
/**
* COMP 520
* Method invocation
*/
class MainClass {
public static void main (String [] args) {
FirstClass f = new FirstClass ();
f.testme ();
}
}
class FirstClass
{
int n;
public void testme ()
{
int tstvar = 10;
System.out.println(tstvar);
}
}

View File

@ -1,37 +0,0 @@
/**
* COMP 520
* Field reference and update
*/
class MainClass {
public static void main (String [] args) {
FirstClass f = new FirstClass ();
f.s = new SecondClass ();
f.s.f = f;
f.testme ();
}
}
class FirstClass
{
int n;
SecondClass s;
public void testme ()
{
int tstvar = 10;
n = 11;
tstvar = s.f.n;
System.out.println(tstvar);
}
}
class SecondClass
{
int n;
FirstClass f;
}

View File

@ -1,42 +0,0 @@
/**
* COMP 520
* Complex method invocation
*/
class MainClass {
public static void main (String [] args) {
FirstClass f = new FirstClass ();
f.s = new SecondClass ();
f.s.f = f;
f.testme ();
}
}
class FirstClass
{
int n;
SecondClass s;
public void testme ()
{
int tstvar = 10;
n = 4;
tstvar = 1 + foo (3, 4);
System.out.println(tstvar);
}
public int foo (int x, int y)
{
return (n + x + y);
}
}
class SecondClass
{
int n;
FirstClass f;
}

View File

@ -1,14 +0,0 @@
/**
* COMP 520
* Array creation and update
*/
class bob {
public static void main(String [] args) {
int a = 2;
int [] b = new int [ 2 * 5 - 3];
b[0] = 13;
boolean c = b[a-2] > a;
if (c)
System.out.println(b[0]);
}
}

View File

@ -1,41 +0,0 @@
/**
* COMP 520
* Recursion
*/
class MainClass {
public static void main (String [] args) {
FirstClass f = new FirstClass ();
f.s = new SecondClass ();
f.s.f = f;
f.testme ();
}
}
class FirstClass
{
int n;
SecondClass s;
public void testme ()
{
int tstvar = 10;
System.out.println(8 + s.fact (3));
}
}
class SecondClass
{
int n;
FirstClass f;
public int fact (int param){
int r = 1;
if (param > 1)
r = param * fact(param - 1);
return r;
}
}

View File

@ -1,46 +0,0 @@
/**
* COMP 520
* Instance values
*/
class MainClass {
public static void main (String [] args) {
FirstClass f = new FirstClass ();
f.s = new SecondClass ();
f.s.f = f;
f.testme ();
}
}
class FirstClass
{
int n;
SecondClass s;
public void testme ()
{
int tstvar = 10;
this.n = 4;
s.n = 5;
System.out.println(2 + this.zoo (this, this.s));
}
public int foo (int x, int y)
{
return (n + x + y);
}
public int zoo (FirstClass first, SecondClass second)
{
return (first.n + second.n + this.n);
}
}
class SecondClass
{
int n;
FirstClass f;
}

View File

@ -1,32 +0,0 @@
/**
* COMP 520
*/
class MainClass {
public static void main (String [] args) {
FirstClass f = new FirstClass ();
f.n = 56;
f.set (999);
System.out.println(f.get());
}
}
class FirstClass
{
int n;
public void set (int value)
{
int temp = 0;
temp = value;
n = temp;
}
public int get ()
{
return n;
}
}

View File

@ -1,30 +0,0 @@
/**
* COMP 520
* Instance values
*/
class MainClass {
public static void main (String [] args) {
FirstClass f = new FirstClass ();
f = f.getAlternate(57);
}
}
class FirstClass
{
public int n;
public FirstClass getAlternate(int v) {
FirstClass fc = new FirstClass();
fc.n = v;
FirstClass rc = fc.getThis();
return rc;
}
public FirstClass getThis() {
return this;
}
}

Some files were not shown because too many files have changed in this diff Show More