7.6实战练习

Juxing类的代码:
 1 package org.hanqi.pn0120;
 2 
 3 public class Juxing {
 4 
 5     double chang;
 6     double kuan;
 7     Juxing(double chang,double kuan)
 8     {
 9         this.chang=chang;
10         this.kuan=kuan;
11     }
12     
13     double mianji()
14     {
15         double s=chang*kuan;
16         return(s);
17     }
18 }
View Code

Test类的代码:

1 package org.hanqi.pn0120;
2 
3 public class Test1 {
4     public static void main(String[] args) {
5     Juxing myjuxing=new Juxing(5d,10d);
6     
7     System.out.println("矩形面积="+myjuxing.mianji());
8     }
9 }
View Code

运行结果图:

posted on 2016-03-04 18:42  beens  阅读(115)  评论(0编辑  收藏  举报

导航