王梦然

2013年3月21日

例题4-9

摘要: class Circle{double radius;Circle(double r){radius=r;}double computerArea(){return 3.14*radius*radius;}void setRadius(double newRadius){radius=newRadius;}double getRadius(){return radius;}}class Cone{Circle bottom;double height;Cone(Circle c,double h){bottom=c;height=h;}double computerVolume(){doubl 阅读全文

posted @ 2013-03-21 20:22 快乐的铲屎官 阅读(170) 评论(0) 推荐(0) 编辑

2013年3月20日

例题4-7向一个方法的基本数据类型参数传值/4-8引用类型参数

摘要: class Tom{void f(int x,double y){x=x+1;y=y+1;System.out.printf("参数x和y的值分别是:%d,%3.2f\n",x,y);}}public class Example4_7{public static void main(String args[]){int x=10;double y=12.58;Tom cat=new Tom();cat.f(x,y);System.out.printf("main方法中x和y的值仍然分别是:%d,%3.2f\n",x,y);}}class Jerry{in 阅读全文

posted @ 2013-03-20 22:49 快乐的铲屎官 阅读(175) 评论(0) 推荐(0) 编辑

例题4-5常量的用法/例题4-6通过类名调用类

摘要: class Tom{final int MAX=100;static final int MIN=20;}public class Example4_5{public static void main(String args[]){System.out.println(Tom.MIN);Tom cat=new Tom();int x=0;x=Tom.MIN+cat.MAX;System.out.println(x);}}class Computer{double x,y;static double max(double a,double b){return a>b?a:b;}}class 阅读全文

posted @ 2013-03-20 22:27 快乐的铲屎官 阅读(115) 评论(0) 推荐(0) 编辑

2013年3月19日

例题4-4(两个Lader对象共享bottom)

摘要: class Lader{double above,height;static double bottom;void setAbove(double a){above=a;}void setBottom(double b){bottom=b;}double getAbove(){return above;}double getBottom(){return bottom;}}class Example4_4{public static void main(String args[]){Lader.bottom=60;Lader laderOne,laderTwo;System.out.print 阅读全文

posted @ 2013-03-19 22:17 快乐的铲屎官 阅读(173) 评论(0) 推荐(0) 编辑

例题4-3

摘要: class Lader{double above,bottom,height;Lader(){}Lader(double a,double b,double h){above=a;bottom=b;height=h;}public void setAbove(double a){above=a;above=a;}public void setBottom(double b){bottom=b;}public void setHeight(double h){height=h;}double computeArea(){return(above+bottom)*height/2.0;}}publ 阅读全文

posted @ 2013-03-19 21:48 快乐的铲屎官 阅读(127) 评论(0) 推荐(0) 编辑

例题4-2

摘要: class Circle{double radius;double getArea(){double area=3.14*radius*radius;return area;}}public class Example4_2{public static void main (String args[]){Circle circle;circle=new Circle();circle.radius=163.16;double area=circle.getArea();System.out.printf("半径是%5.3f的圆的面积:\n%5.3f\n",circle.ra 阅读全文

posted @ 2013-03-19 21:16 快乐的铲屎官 阅读(115) 评论(0) 推荐(0) 编辑

输出圆的面积的Java程序

摘要: public class ComputerCircleArea{public static void main(String args[]){double radius;double area;radius=163.16;area=3.14*radius*radius;System.out.printf("半径是%5.3f的圆的面积:\n%5.3f\n",radius,area);}} 阅读全文

posted @ 2013-03-19 16:54 快乐的铲屎官 阅读(723) 评论(0) 推荐(0) 编辑

2013年3月17日

书上例题练习第三章(下)

摘要: 阅读全文

posted @ 2013-03-17 16:25 快乐的铲屎官 阅读(118) 评论(0) 推荐(0) 编辑

2013年3月16日

书上例题练习第三章(上)

摘要: 阅读全文

posted @ 2013-03-16 13:42 快乐的铲屎官 阅读(108) 评论(0) 推荐(0) 编辑

书上例题练习第二章

摘要: 阅读全文

posted @ 2013-03-16 12:16 快乐的铲屎官 阅读(76) 评论(0) 推荐(0) 编辑

导航