2个回答
展开全部
用春敏信这个肯定可以
public class Rectangle {
private float width;//长
private float height;//宽
public Rectangle(float width, float height){
this.width = width;
this.height = height;
}
//计扒轮算周长= (长拿运+宽)*2
public float calcCircle(){
return (width + height) * 2;
}
//计算面积 长*宽
public float calcArea(){
return width * height;
}
public float getHeight() {
return height;
}
public void setHeight(float height) {
this.height = height;
}
public float getWidth() {
return width;
}
public void setWidth(float width) {
this.width = width;
}
}
public class Rectangle {
private float width;//长
private float height;//宽
public Rectangle(float width, float height){
this.width = width;
this.height = height;
}
//计扒轮算周长= (长拿运+宽)*2
public float calcCircle(){
return (width + height) * 2;
}
//计算面积 长*宽
public float calcArea(){
return width * height;
}
public float getHeight() {
return height;
}
public void setHeight(float height) {
this.height = height;
}
public float getWidth() {
return width;
}
public void setWidth(float width) {
this.width = width;
}
}
展开全部
import java.awt.*;
import javax.swing.*;
public class drawRech extends JApplet {
public void paint(Graphics g){
super.paint(g);
this.setBackground(Color.WHITE);
String width = JOptionPane.showInputDialog("Enter the width");
String height = JOptionPane.showInputDialog("Enter the height"清镇);
int wid = 0;
int heig = 0;
try{
wid = Integer.parseInt(width);
heig = Integer.parseInt(height);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "Wrong input");
}
g.drawRect(100, 100, wid, heig);
}
}
已添加异租正桥常处理,测试成弊猛功
import javax.swing.*;
public class drawRech extends JApplet {
public void paint(Graphics g){
super.paint(g);
this.setBackground(Color.WHITE);
String width = JOptionPane.showInputDialog("Enter the width");
String height = JOptionPane.showInputDialog("Enter the height"清镇);
int wid = 0;
int heig = 0;
try{
wid = Integer.parseInt(width);
heig = Integer.parseInt(height);
}
catch(NumberFormatException e){
JOptionPane.showMessageDialog(null, "Wrong input");
}
g.drawRect(100, 100, wid, heig);
}
}
已添加异租正桥常处理,测试成弊猛功
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询