Initial commit
This commit is contained in:
29
Example_src/Chapter1-10/src/ch04/TestAddChengji.java
Normal file
29
Example_src/Chapter1-10/src/ch04/TestAddChengji.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package ch04;
|
||||
|
||||
import java.applet.*;
|
||||
import java.awt.*;
|
||||
|
||||
class Chengji {
|
||||
float fun(float x, float y) {
|
||||
return x * y;
|
||||
}
|
||||
}
|
||||
|
||||
class AddChengji extends Chengji {
|
||||
float fun(float x, float y) {
|
||||
return x + y;
|
||||
}
|
||||
}
|
||||
|
||||
public class TestAddChengji extends Applet {
|
||||
AddChengji sum;
|
||||
|
||||
public void init() {
|
||||
sum = new AddChengji();
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
g.drawString("sum=" + sum.fun(4, 6), 100, 40);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user