扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
Java程序:
成都创新互联公司是一家专业提供南康企业网站建设,专注与成都网站设计、做网站、H5响应式网站、小程序制作等业务。10年已为南康众多企业、政府机构等服务。创新互联专业的建站公司优惠进行中。
public class Main {
public static void main(String[] args) {
Shape s = null;
s = new Circle(3);
System.out.println("圆的面积:" + s.area());
System.out.println("圆的周长:" + s.perimeter());
}
}
/**
* 形状类:抽象类
* @author developer
* @version 2017.05.23
*/
abstract class Shape {
/**
* 计算形状的面积
* @return 形状的面积
*/
abstract double area();
/**
* 计算形状的周长
* @return 形状的周长
*/
abstract double perimeter();
}
/**
* 圆类
* @author developer
* @version 2017.05.23
*/
class Circle extends Shape {
/**
* 半径
*/
protected double radius;
/**
* 构造方法
* @param radius 半径
*/
public Circle(double radius) {
this.radius = radius;
}
@Override
double area() {
return Math.PI * radius * radius;
}
@Override
double perimeter() {
return 2 * Math.PI * radius;
}
}
运行测试:
圆的面积:28.274333882308138
圆的周长:18.84955592153876
MapCalendar,Double map= new HashMapCalendar,Double();
时间和值组成的集合。
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.geom.*;
/**
* @author Hardneedl
*/
class RectTransform extends JFrame {
private static final Dimension minSize = new Dimension(300, 200);
private static final Dimension maxSize = new Dimension(1024, 768);
private static final Dimension preferredSize = new Dimension(600, 400);
public Dimension getMaximumSize() {return maxSize;}
public Dimension getMinimumSize() {return minSize;}
public Dimension getPreferredSize() {return preferredSize;}
public String getTitle() {return "Frame Title";}
private AffineTransform af = new AffineTransform();
private Stroke stroke = new BasicStroke(2.0f);
private Rectangle rct = new Rectangle(40,140,200,140);
private JComponent canvas = new JComponent(){
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.setColor(Color.BLACK);
g.fillRect(0,0,getWidth(),getHeight());
Graphics2D g2d = (Graphics2D)g.create();
g2d.setColor(Color.YELLOW);
g2d.setTransform(af);
g2d.setStroke(stroke);
g2d.draw(rct);
g2d.dispose();
}
};
RectTransform() throws HeadlessException {
init();
doLay();
attachListeners();
}
private void init() {
}
private void doLay() {
Container container = getContentPane();
JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER,30,5));
panel.add(new JButton( new AfAction("move", AffineTransform.getTranslateInstance(100,100)) ));
panel.add(new JButton( new AfAction("rotate", AffineTransform.getRotateInstance(Math.PI/3,40,120) ) ));
panel.add(new JButton( new AfAction("zoomIn", AffineTransform.getScaleInstance(2,2)) ));
panel.add(new JButton( new AfAction("ZoomOut", AffineTransform.getScaleInstance(.5d,.5d)) ));
panel.add(new JButton( new AfAction("Original", new AffineTransform()) ) );
container.add(panel,BorderLayout.NORTH);
container.add(canvas,BorderLayout.CENTER);
pack();
}
private void attachListeners() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private class AfAction extends AbstractAction {
private AffineTransform aff;
private AfAction(String n,AffineTransform af) {
super(n);
this.aff = af;
}
public void actionPerformed(ActionEvent e) {
af.setTransform(aff);
if(canvas.isVisible()) canvas.paintImmediately(0,0,getWidth(),getHeight());
}
}
public static void main(String[] args) {
new RectTransform().setVisible(true);
}
}
我是来拿分的,基础的编程而已,花在JAVA上的时间不够,希望你能找到答案,不过学好JAVA还是要靠自己
地图拥用个二维数组,A,B的逻辑分别判断,Aif(i(数组高度)= 0,j != 0 )(j--),if(j = 0,i = 0)(i ++),if(i != 0,j == 0)(j ++)if(i == 10, j == 10)(i --)B的逻辑与A反下,就可以了
方法1、对数坐标系下画图;semilogx,semilogy,loglog
方法2、求差值并画图;
方法3、局部放大;
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流