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
相关问答:
字符流的读和写最终在底层都是通过字节流来完成的吗? 读写文本文件字符流应该就可以了吧。。
各位大哥大姐帮帮忙阿
Java流包括字节流和字符流,字节流通过IO设备以字节数据的方式读入,而字符流则是通过字节流 ......
import java.io.*;
class FileTest
{
public static void main(String [] args) throws Exception
{
File fDir=new File(File.separator);
String strFile="java源代码测试"+File.separato ......
public class Student{
//字段的定义
private String _number; //学号
private String _name; //姓名
private   ......
在安装Java编译器的Eclipse的时候,对环境变量进行了配置,在安装MySQl的时候也要对环境变量进行配置;那么后面的配置会影响前面的Eclipse的配置吗?
请大家多指教~!谢谢!
不会把,我这都装了的 我系统里 还装了 ......