Skip to content

Commit b4d9d4a

Browse files
committed
Progress
1 parent ee2298e commit b4d9d4a

File tree

5 files changed

+37
-7
lines changed

5 files changed

+37
-7
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ a.out
33
*.o
44
*.s
55
*.bak
6+
*.jar
7+
*.class
68
.DS_Store
79
cc4e-private
810
jail

lectures/code/Point.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import java.lang.Math;
2+
3+
public class Point {
4+
double x,y;
5+
6+
Point(double x, double y) {
7+
this.x = x;
8+
this.y = y;
9+
}
10+
11+
void dump() {
12+
System.out.println(this+" x="+this.x+" y="+this.y);
13+
}
14+
15+
double origin() {
16+
return Math.sqrt(this.x*this.x+this.y*this.y);
17+
}
18+
}

lectures/code/cc_03_01.java

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
public class cc_03_01 {
2+
3+
public static void main(String[] args)
4+
{
5+
System.out.println("In Main");
6+
Point pt = new Point(4.0, 5.0);
7+
pt.dump();
8+
System.out.println("Origin "+pt.origin());
9+
}
10+
}
11+
12+
// javac Point.java ; javac cc_03_01.java ; java cc_03_01

lectures/code/cc_03_02.c

-6
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
#include <stdlib.h>
33
#include <math.h>
44

5-
struct point
6-
{
7-
double x;
8-
double y;
9-
};
10-
115
struct PointStruct {
126
double x;
137
double y;

lectures/code/cc_03_03.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ def __init__(self, x, y):
1111
self.y = y
1212

1313
def dump(self):
14-
print('Object %s@%x x=%f y=%f' % (self.label, id(self),self.x,self.y))
14+
print('Object %s@%x x=%f y=%f'
15+
% (self.label, id(self),self.x,self.y))
1516

1617
def origin(self):
1718
return math.sqrt(self.x*self.x+self.y*self.y)
@@ -21,5 +22,8 @@ def origin(self):
2122
PointClass.dump(pt)
2223
print('Origin',pt.origin())
2324

25+
PointClass.label = "dot"
26+
PointClass.dump(pt)
27+
2428
del(pt)
2529

0 commit comments

Comments
 (0)