第十二次Java作业
Posted w-j
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第十二次Java作业相关的知识,希望对你有一定的参考价值。
public class eee { int x; int y; public eee(int x0,int y0){ x=x0; y=y0; } public eee(){ } public String movePoint(int dx,int dy){ x+=dx; y+=dy; return ("x"+x+" "+"y"+y); } public static void main(String[] args) { eee p1=new eee(1,5); System.out.println("p1是"+p1.movePoint(1, 5)); eee p2=new eee(2,3); System.out.println("p2是"+p2.movePoint(2, 3)); } }
public class eee { int length; int width; public int getArea(int length,int width){ return length*width; } public int getPer(int length,int width){ return (length+width)*2; } public void shwAll(){ System.out.println("length=" + length + " "+" width=" + width + " "+"周长"+(length+width)*2+" "+"面积"+length*width); } public eee (int length,int width){ this.length=length; this.width=width; } public static void main(String[] args) { eee a=new eee(7,2); a.shwAll(); } }
public class eee { char color; int cpu; public eee(){ } public eee(char color,int cpu){ this.color =color; this.cpu=cpu; } public void show(){ System.out.println("笔记本颜色是"+color+" "+"型号是"+cpu); } public static void main(String[] args) { // TODO Auto-generated method stub eee a1=new eee (\'粉\',3); eee a2=new eee(\'红\',2); a1.show(); a2.show(); } }
以上是关于第十二次Java作业的主要内容,如果未能解决你的问题,请参考以下文章