class Fraction {
int n;
int d;
Fraction (int a, int b) {
n = a;
d = b;
}
void add (int z) {
this.n = this.d*z+this.n;
}
String toString() {
String s = this.n+"/"+this.d;
return s;
}
void reciprocal() {
int tmp;
tmp = n;
n = d;
d = tmp;
}
}
void setup() {
size (50, 30);
background (0, 0, 255);
Fraction f = new Fraction (5, 9);
f.add (3);
text (f.toString(), 15, 20);
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น