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> ...
随机推荐
- js中加“var”和不加“var”的区别,看完觉得这么多年js白学了
Javascript声明变量的时候,虽然用var关键字声明和不用关键字声明,很多时候运行并没有问题,但是这两种方式还是有区别的.可以正常运行的代码并不代表是合适的代码. var num = 1: 是在 ...
- 使用sqlparse分析SQL语句,及自己写的SQL分析语句
备忘, 以后写的时候可以参考. #!/usr/bin/env python # -*- coding: utf-8 -*- import sqlparse import re sql = " ...
- 两个 DataTable 读取重复数据
今天正好用到Excel 导入转换成table , 文件中数据要和数据库里数据进行比对,有重复的抛出重复数据. 和大家分享下,欢迎高手留言指点.有问题可以留言关注! /// <summary> ...
- R语言实战读书笔记(七)基本统计分析
summary() sapply(x,fun,options):对数据框或矩阵中的每一个向量进行统计 mean sd:标准差 var:方差 min: max: median: length: rang ...
- Linux Root下的.gvfs出现异常解决办法(导致source失败,自启动失败)
原文地址: http://www.cnblogs.com/tdyizhen1314/p/4142991.html 在linux系统下安装软件或复制文件的时候,复制不成功,出现错误如下: error ...
- boost::function和boost::bind 介绍
一. boost::function介绍 原文:http://www.cnblogs.com/sld666666/archive/2010/12/16/1907591.html 本片文章主要介绍boo ...
- 服务器SSL/TLS快速检测工具TLLSSLed
服务器SSL/TLS快速检测工具TLLSSLed 现在SSL和TLS被广泛应用服务器的数据加密中,如网站的HTTPS服务.所以,在渗透测试中如何快速检测服务器的SSL和TLS配置寻找安全漏洞,就显 ...
- 平衡树与可持久化treap
平衡树(二叉树) 线段树不支持插入or删除一个数于是平衡树产生了 常见平衡树:treap(比sbt慢,好写吧),SBT(快,比较好写,有些功能不支持),splay(特别慢,复杂度当做根号n来用,功能强 ...
- Codechef FNCS Chef and Churu
Disciption Chef has recently learnt Function and Addition. He is too exited to teach this to his fri ...
- 正确使用Block避免Cycle Retain和Crash
Block简介 Block作为C语言的扩展,并不是高新技术,和其他语言的闭包或lambda表达式是一回事.需要注意的是由于Objective-C在iOS中不支持GC机制,使用Block必须自己管理内存 ...