shapes
接口 shape
package shape;
public abstract interface shape {
public abstract void Draw();
public abstract void getString();
public static void main(String[] args) {
}
}
实体类矩形
package shape;
public class Rect implements shape{
private int length = 0;
private int wideth = 0;
public Rect(int length,int wideth){
this.length = length;
this.wideth = wideth;
}
public void Draw(){
System.out.println("Draw Rect");
}
public void getString() {
System.out.println("Rect [length=" + length + ", wideth=" + wideth + "]");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}
实体类 圆
package shape;
public class Circle implements shape{
private int Radius = 0;
public Circle(int Radius){
this.Radius = Radius;
}
public void Draw(){
System.out.println("Draw Circle");
}
public void getString() {
System.out.println("Circle [Radius=" + Radius + "]");
}
public static void main(String[] args) {
}
}
多态 操作
package shape;
public class Board {
public shape[] S = { new Circle(1), new Circle(2)
, new Circle(3), new Rect(1,2)
, new Rect(2,3), new Rect(3,4) };
public void Refresh(shape s) {
s.Draw();
s.getString();
}
public static void main(String[] args) {
Board B = new Board();
for (int i = 0; i < 6; i++) {
B.Refresh(B.S[i]);
}
}
}
shapes的更多相关文章
- 十二、shapes
1. The control points are attributes on the shape which are usually arrays of points. Control points ...
- Allegro Out Of Date Shapes原因及解决方法
使用Allegro设计PCB板时,查看Status,经常会遇到out of date shapes的警告信息,具体如下: dynamic shape is still out of data or e ...
- Topology Shapes of OpenCascade BRep
Topology Shapes of OpenCascade BRep eryar@163.com 摘要Abstract:通过对OpenCascade中的BRep数据的读写,理解边界表示法的概念及实现 ...
- graphviz - Node Shapes
Node Shapes There are three main types of shapes : polygon-based, record-based and user-defined. The ...
- POJ 3449 Geometric Shapes(判断几个不同图形的相交,线段相交判断)
Geometric Shapes Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1243 Accepted: 524 D ...
- Geometric Shapes - POJ 3449(多边形相交)
题目大意:给一些几何图形的编号,求出来这些图形都和那些相交. 分析:输入的正方形对角线上的两个点,所以需要求出来另外两个点,公式是: x2:=(x1+x3+y3-y1)/2; y2:=(y1+y3 ...
- 详细分析Orchard的Content、Drivers, Shapes and Placement 类型
本文原文来自:http://skywalkersoftwaredevelopment.net/blog/a-closer-look-at-content-types-drivers-shapes-an ...
- POJ 3449 Geometric Shapes (求正方形的另外两点)
Geometric Shapes Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 1470 Accepted: 622 D ...
- 解决gerber-Failed to Match All Shapes for PCB问题
有效解决在Protel 99se导gerber时提示gerber-Failed to Match All Shapes for PCB出错问题如图 这种问题很好解决,打开这个窗口 操作方法如下图Emb ...
- 【python问题系列--4】ValueError: operands could not be broadcast together with shapes (100,3) (3,1)
背景:dataMatrix是(100,3)的列表,labelMat是(1,100)的列表,weights是(3,1)的数组,属性如下代码所示: >>> import types> ...
随机推荐
- Group by 两表联查取另一表与之关联数据的总数
使用group by 需要查询的字段 必须要放在group by 后面 SELECT U.UserLotterySn,count(W.Userlotterysn) as WinCount,U.Acti ...
- jquery 焦点轮播图控制每张图片停留不同时间
轮播代码是代签博客园一位前辈写的代码,这里作了点小修改,实现了每张图片停留不同时间 *{ padding:0px; border:0px; margin:0px; } ul { list-style: ...
- codevs——1008 选数
1008 选数 2002年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题解 题目描述 Description 已知 n ...
- 高并发场景下System.currentTimeMillis()的性能优化
一.前言 System.currentTimeMillis()的调用比new一个普通对象要耗时的多(具体耗时高出多少我也不知道,不过听说在100倍左右),然而该方法又是一个常用方法, 有时不得不使用, ...
- tensorflow global_variables_initializer()
老版本为 init = tf.initialize_all_variables() 新版本为 init = tf.global_variables_initializer()
- 老毛桃winpe优盘启动系统个性修改全攻略
PE优盘系统也有很多:大白菜.老毛桃.深度.通用PE工具箱.U大师.电脑店……这些PE优盘系统大多都会捆绑软件安装.更改主页等,一不小心,你就中招.虽然有些是可以自己去取消,但是启动画面还是带有各种L ...
- inputclean插件的使用方法
inputclean插件的使用方法 语言:javascript 是jquery插件, 目的:给文本框添加×,点击×,就可以清空文本框内容. 如图: 详细交互效果: 1,当文本框聚焦时,×永久显示,无论 ...
- sdut 面向对象程序设计上机练习九(对象指针)
面向对象程序设计上机练习九(对象指针) Time Limit: 1000MS Memory limit: 65536K 题目描写叙述 建立对象数组,内放5个学生数据(学号是字符串类型.成绩是整型).设 ...
- mysql_config_editor使用简介
原文 : http://blog.itpub.net/29773961/viewspace-1817640/ ----------------------------------------- ...
- IntelliJ IDEA 10.5.1 引用外部Jar包
具体步骤: File -> Project Structure (ctrl + shift + alt + s ) -> Module -> Dependencies -> A ...