?? java.txt
字號:
public class Rectangle {
protected double length=0,circulme=0,width=0,area=0;
public Rectangle()
{
length=0;
width=0;
}
public Rectangle(double length,double width)
{
this.length=length;
this.width=width;
circulme=2*(length+width);
area=length*width;
}
void SetRectangle(double length,double width)
{
this.length=length;
this.width=width;
circulme=2*(length+width);
area=length*width;
}
double GetCirculme()
{
return circulme;
}
double GetArea()
{
return area;
}
}
import javax.swing.JOptionPane;
public class TestRectangle {
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成方法存根
/*double width=0,length=0;
String st1=JOptionPane.showInputDialog(null,"請輸入長:","0");
String st2=JOptionPane.showInputDialog(null,"請輸入寬:","0");
length=Double.parseDouble(st1);
width=Double.parseDouble(st2);
Rectangle re=new Rectangle(length,width);
System.out.println("The circulme is: "+re.GetCirculme());
System.out.println("The area is: "+re.GetArea());
st1=Double.toString(re.GetCirculme());
st2=Double.toString(re.GetArea());
JOptionPane.showMessageDialog(null,"The circulme is: "+st1);
JOptionPane.showMessageDialog(null,"The area is: "+st2);*/
double edge=0;
String st=JOptionPane.showInputDialog(null,"請輸入正方形邊長:","0");
edge=Double.parseDouble(st);
Square square=new Square(edge);
String st3=Double.toString(square.GetCirculme());
String st4=Double.toString(square.GetArea());
JOptionPane.showMessageDialog(null,"The circulme is: "+st3);
JOptionPane.showMessageDialog(null,"The area is: "+st4);
}
}
public class Square extends Rectangle{
double edge=0;
public Square(){}
public Square(double edge){
super(edge,edge);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -