我对Java很陌生,对绘制梯形有疑问 . 目前我不知道从哪里开始 . 你有什么想法,我可以在哪里开始,以及要照顾什么?我不想从中得到完整的代码,只是一些灵感,因为此刻我真的不知道

/*

* Trapezium.java -

*/

/**

* Represents a isosceles trapezium, that can be 'drawn' to the standard

* output stream. A trapezium is drawn with a foreground and background colour.

* The fore- and background colours are represented by two (different) characters.

* Each trapezium consists of a number of individual lines. Each line contains an

* odd number of foreground characters to be able to retain symmetry.

*/

public class Trapezium {

// Attributes/ Fields

/**

* The character representation of the default background.

*/

private static final char DEFAULT_BACKGROUND = 32;

/**

* The character representation of the default foreground.

*/

private static final char DEFAULT_FOREGROUND = 42;

/**

* The character representation of the indentation.

*/

private static final char INDENTATION = 32;

/**

* The number of lines used to draw the triangle itself.

*/

private int height;

/**

* The maximal number of characters per line used to draw the

* trapezium itself.

*/

private int width;

/**

* The size of the margin in characters.

*/

private int margin;

/**

* The foreground character.

*/

private char foreground;

/**

* The background character.

*/

private char background;

/**

* The number of characters at the top line of

* the trapezium.

*/

private int topWidth;

/**

* The number of characters at the bottom line of the trapezium.

*/

private int bottomWidth;

// Constructor

/**

* Creates a trapezium accepting a top and bottom width,

* a fore- and a background character as well as a value

* for the margin.

*

* @param topWidth - the width at the top of the trapezium as a non-negative number.

* @param bottomWidth - the width at the bottom of the trapezium as a non-negative number.

* @param foreground - the character used to draw the trapezium's foreground

* @param background - the character used to draw the trapezium's background

* @param margin - the non-negative number of characters to be used as margin at the left

* and right of the trapezium

*

*/

public Trapezium(int topWidth, int bottomWidth,

char foreground, char background,

int margin) {

this.topWidth = topWidth;

this.bottomWidth = bottomWidth;

this.foreground = foreground;

this.background = background;

this.margin = margin;

}

/**

* Creates a trapezium with the given width at the top and bottom

* and the size of the margin.

* Default values are used for the foreground and background.

*

* @param topWidth - the width at the top of the trapezium as a non-negative odd number.

* @param bottomWidth - the width at the bottom of the trapezium as a non-negative odd number.

* @param margin - the non-negative number of characters to be used as margin at the left

* and right of the trapezium

*

*/

public Trapezium(int topWidth,

int bottomWidth,

int margin) {

this.topWidth = topWidth;

this.bottomWidth = bottomWidth;

this.margin = margin;

}

/**

* Creates a trapezium without a margin with the given width at the top and bottom.

* Default values are used for the foreground and background.

*

* @param topWidth - the width at the top of the trapezium as a non-negative odd number.

* @param bottomWidth - the width at the bottom of the trapezium as a non-negative odd number.

*/

public Trapezium(int topWidth,

int bottomWidth) {

this.topWidth = topWidth;

this.bottomWidth = bottomWidth;

}

// Methods

/**

* Draws the triangle with no indentation.

* This method calls the more general 'draw' method.

*/

public void draw() {

// while

}

/**

* Draws the triangle with the given indentation.

*

* @param indentation - the indentation at which the triangle is drawn

*

*/

public void draw(int indentation) {

;

//while

}

/**

* Rotates the triangle 180 degrees.

*

*/

public void rotate() {

;

}

/**

* Prints a 'run' of a given character.

*

* @param character - the character to be repeated.

* @param length - the number of characters to print.

*

*/

private void printCharacterRun(char character, int length) {

;

}

/**

* Adds a newline to the output.

*

*/

private void printNewLine() {

}

}

测试员在另一个 class

trapezium = new Trapezium(5, 11, '*', '-', 2); // create a new Trapezium

trapezium.draw();

trapezium.rotate();

trapezium.draw(15);

java梯形_如何绘制梯形?相关推荐

  1. lisp如何绘制梯形_CAD怎么绘制梯形-CAD常见问题-广州中望龙腾软件股份有限公司WWW.ZWCAD.COM...

    CAD怎么绘制梯形 怎么用CAD绘制一个梯形呢?梯形是CAD中比较常见的基本图形,除了特殊的梯形之外,我们如何通过已知几条边长,来画一个梯形呢?下面小编通过直线工具给大家画一个上底是15,下底是78, ...

  2. 双泳道活动图java代码_如何绘制泳道图(跨职能流程图)

    如何定义"泳道图"?泳道图也叫跨职能流程图,旨在展示工作流中每个步骤涉及的流程和职能部门.泳道流程图是一种特殊的图表可以展示出一个商业过程之间的关系,并展示为那个过程负责的功能板块 ...

  3. java 在底图上绘制线条_使用底图和geonamescache绘制k表示聚类

    java 在底图上绘制线条 This is the third of four stories that aim to address the issue of identifying disease ...

  4. java canvas 画图片_[Java教程][HTML5] Canvas绘制简单图片

    [Java教程][HTML5] Canvas绘制简单图片 0 2016-05-13 13:00:04 获取Image对象,new出来 定义Image对象的src属性,参数:图片路径 定义Image对象 ...

  5. Java中山脉的绘制---递归方法

    ** Java中山脉的绘制-递归方法 ** 一.山脉绘制的思路: 给定两个点A(x1,y1),B(x2,y2),递归不断取中点,同时给定一个范围[-range,range]和一个比率rate.每次取中 ...

  6. matlab图形绘制经典案例,MATLAB经典教程第四章_图形绘制.ppt

    <MATLAB经典教程第四章_图形绘制.ppt>由会员分享,可在线阅读,更多相关<MATLAB经典教程第四章_图形绘制.ppt(32页珍藏版)>请在人人文库网上搜索. 1.Ma ...

  7. JAVA入门_多线程_邮局派发信件

    JAVA入门_多线程_邮局派发信件 Postman package cn.campsg.java.experiment.entity;public class Postman {private Str ...

  8. 第一段Java程序_借助Win控制命令台编译执行 编辑器Notepad++

    第一段Java程序_借助Win控制命令台编译执行 编辑器Notepad++ 准备代码: 第一次编译: 显然需要先配置环境变量: 先找到java.exe和javac.exe所在的文件夹位置: 此电脑-& ...

  9. java 多线程写缓存,Java多线程_缓存对齐

    1.什么是缓存对齐 当前的电脑中,数据存储在磁盘上,可以断电保存,但是读取效率较低.不断电的情况下,数据可以在内存中存储,相对硬盘效率差不多是磁盘的一万倍左右.但是运算时,速度最快的是直接缓存在CPU ...

  10. 复习Java异常处理_异常分类_自定义异常_线程初步了解

    复习Java异常处理_异常分类_自定义异常_线程 主要内容 异常.线程 教学目标 第一章 异常 1.1 异常概念 异常,就是不正常的意思.在生活中:医生说,你的身体某个部位有异常,该部位和正常相比有点 ...

最新文章

  1. 微信怎么at所有人_任正非被遗漏的讲话:怎么做一个谦虚的领导者?
  2. F5负载均衡的初识和基本配置
  3. 信息安全之仿射密码加密和解密
  4. 用 php写的条件语句-三种条件语句
  5. PIManager V1.0 Release -[2007-06-05]
  6. 鼻塞用鼻喷剂-调研(成分+刺激性)
  7. GARFIELD@12-30-2004
  8. 2019计算机开机号003期,2019年011期福彩中心开机号(附汇总)
  9. linux中fdisk的参数,Linux fdisk命令参数及用法详解--Linux磁盘分区管理命令fdisk
  10. 单例模式-双重检查加锁
  11. php跳转方式带rere_PHP利用REFERER根居访问来地址进行页面跳转
  12. 读书笔记-《 我的成功可以复制》四
  13. 【无人机控制】四旋翼飞行器飞行控制系统含Matlab源码
  14. 人生终归平淡,转:为什么我们对平凡的人生深怀恐惧
  15. Android 做一个简单记事本app
  16. 银行软件性能测试,银行手机银行系统性能测试方案.pdf
  17. 计算机毕业设计之java+ssm学生网上请假系统
  18. QMap 迭代器崩溃分析
  19. mysql最新版安装
  20. Twitter推特爬虫工具开发

热门文章

  1. mach ipc 学习
  2. 与 WinHTTP Web Proxy Auto-Discovery Service 服务相依的 DHCP Client 服务因下列错误而无法启动
  3. 【linux】正点原子linux教程学习
  4. 3D游戏场景模型制作的细节与技巧
  5. 利用bootstrap实现的响应式导航条
  6. 游吟诗人之中二病犯了
  7. C++20新特性个人总结
  8. python打印列表的下标和值的例子:
  9. 嵌入式系统开发-麦子学院(15)-根文件系统
  10. 法宝合成时的五行位置分配是什么