java中的Shape类
Given four shapes a,b,c,d:
a "0 0 0 1 1 1 1 0"
b "10 10 10 11 11 11 11 10"
c "0.5 0.5 0.5 -10 1.5 0"
d "0.5 0.5 0.75 0.75 0.75 0.2"
我要请教的是:如何用Java语言声明shape类及其四个对象a,b,c,d。注意:a中内容是4个point(点)(0,0)(0,1)(1,1)(1,0).b,c,d也是一样。
API中没有就只能自己写方法传参数了
怎么写啊?
Java code:
Class Shape
{
double[] points = new double[8];
public Shape(String pointsString)
{
....... //String array to number array
}
}
Shape a = new Shape(strA);
Java code:
public static void main(String[] args)
{
String a = "0 0 0 1 1 1 1 0";
shape(a);
}
private static void shape(String a)
{
String[] strings = a.split(" ");
StringBuffer sb = new StringBuffer();
for (int i = 0; i < strings.length; i++)
{
String string = strings[i];
if ((i + 1) % 2 == 0)
{
sb.append(string);
System.out.println(sb);
sb = new StringBuf
相关问答:
我想做够购物车用session 但是不知道怎么获取购买数量 谁有具体的代码吗 希望能割舍
下面是购物车的核心代码
有了这个 就应该能够做出来吧
Java code:
public void doPost(HttpServletRequest reque ......
我想用Java写一个程序,就是我想在运行代码后,在指定的时间打开某程序,例如我运行代码后,讲在12:00打开"D:\Program Files\Tencent\QQ2009\Bin\QQ.exe"这个程序,求高人指点。还有可能的话在指定的时间 ......
public class Student{
//字段的定义
private String _number; //学号
private String _name; //姓名
private   ......
我的Mysql 使用的时候 用dos建立的数据表 在dos中能显示出中文
但是在 其他的可视页面 和网页中都显示乱码 如何解决?
在mysql控制台:show variables like 'char%';贴结果出来看看。
mysql命令行模式下: ......