张学勇移民公司
微信扫一扫 分享朋友圈

已有 2208 人浏览分享

开启左侧

有没有java大人 问个火星问题.

[复制链接]
2208 16
火星叔叔  曼省名人  发表于 2007-10-28 20:41:54 | 显示全部楼层
修不成正果了~
越写越乱
我是乖乖她爸爸

举报 使用道具

回复 支持 反对
Family  贵宾  发表于 2007-10-28 21:05:27 | 显示全部楼层
那你去修无花果吧!!
无聊的猪猪!郁闷的肥肥!!懒惰的胖胖!!!

举报 使用道具

回复 支持 反对
火星叔叔  曼省名人  发表于 2007-10-29 10:25:50 | 显示全部楼层
不知道这里应该怎样改了。怎么写都差一点。import java.util.*;
public class Assignment3 {
public static void main (String[] args) {
  ArrayList lists;
lists = constructLists(\\"a3q1.txt\\");
}
//构造ArrayList
public static ArrayList constructLists(String filename) {
  BufferedReader in;
  ArrayList lists_temp = new ArrayList();
String line1,line2,line3;
try {
   in = new BufferedReader(new FileReader(filename));
   line1 = in.readLine();
   while (line1 != null) {
    line2 = in.readLine();
    line3 = in.readLine();
lists_temp.add(new (list)list(line1,line2,line3));
line1 = readLine();
   }
  } catch (IOException ioe) {
   System.out.println(getMessage());
   ioe.printStackTrace();
  }
  return lists_temp;
}
class list {
public double double_val;
public Point p;
public String text;
public list(String s1,String s2, String s3) {
  this.double_val = Double.parseDouble(s1);
  this.p = new Point(s2);
  this.text = s3;
  //不知道这里是不是要写:
  //return list;
}
public String toString() {
  //输出List
}
}
//point (x,y)
class Point {
  private double x,y;
public Point(double a,double b) {
   this.x = a;
   this.y = b;
  }
public Point(String str) {
   String s;
   String[] tokens;
s = str.replaceAll(\\"(\\",\\"\\");
   s = str.replaceAll(\\")\\",\\"\\");
tokens = line.split(\\",\\");
   //用token来获取point(double a, double b)的a 和 b
   this.x = Double.parseDouble(tokens[0]);
   this.y = Double.parseDouble(tokens[1]);
  }
public String toString() {
   return \\"( \\" + x + \\", \\" + y + \\" )\\";
  }
}
}

[ 本帖最后由 火星叔叔 于 2007-10-29 10:29 编辑 ]
我是乖乖她爸爸

举报 使用道具

回复 支持 反对
MarkebeX  曼省新人  发表于 2007-10-29 14:20:16 | 显示全部楼层
class List()里的 public class() 不用写return的 ,因为是个constructor~

举报 使用道具

回复 支持 反对
就是一枪  管理员  发表于 2007-11-1 20:23:32 | 显示全部楼层
import java.util.*;
import java.io.*;


public class abcdefg {
        public static void main (String[] args) {

                ArrayList lists;
                lists = constructLists(\"file.txt\");
                System.out.println(lists.toString());

        }

        //构造ArrayList
        public static ArrayList constructLists(String filename) {
                BufferedReader in;
                ArrayList lists_temp = new ArrayList();

                String line1,line2,line3;
                try {
                        in = new BufferedReader(new FileReader(filename));
                        line1 = in.readLine();
                        while (line1 != null) {

                                line2 = in.readLine();
                                line3 = in.readLine();

                                list oList = new list(line1,line2,line3);

                                lists_temp.add(oList);

                                line1 = in.readLine();
                        }
                } catch (IOException ioe) {
                        System.out.println(ioe.getMessage());
                        ioe.printStackTrace();
                }
                return lists_temp;
        }
}

class list {
        private double double_val;
        private String double_str;
        private Point p;
        private String text;

        public list(String s1,String s2, String s3) {
                this.double_str = s1;
                this.double_val = Double.parseDouble(s1);
                this.p = new Point(s2);
                this.text = s3;
        }

        public String toString() {
                //输出List
                String s = \"\\n\" + this.double_str ;
                s = s + \"\\n\" + this.p.toString() ;
                s = s + \"\\n\" + this.text ;
                return s;
        }
}


        //point (x,y)
class Point {
                private double x,y;

                public Point(double a,double b) {
                        this.x = a;
                        this.y = b;
                }

                public Point(String str) {
                        String s;
                        String[] tokens;

                        //System.out.println(char(1));

                        s = str.replaceAll(\"\\\\(\",\"\");
                        s = s.replaceAll(\"\\\\)\",\"\");

                        tokens = s.split(\",\");
                        //用token来获取point(double a, double b)的a 和 b
                        this.x = Double.parseDouble(tokens[0]);
                        this.y = Double.parseDouble(tokens[1]);
                }



                public String toString() {
                        return \"( \" + x + \", \" + y + \" )\";
                }
        }

举报 使用道具

回复 支持 反对
火星叔叔  曼省名人  发表于 2007-11-1 21:00:26 | 显示全部楼层
。。。。。
得加油了
我是乖乖她爸爸

举报 使用道具

回复 支持 反对
david1987  禁止发言  发表于 2007-11-1 21:19:42 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

举报 使用道具

回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

0

关注

1

粉丝

104

主题
精彩推荐
热门资讯
网友晒图
图文推荐

维权声明:本站有大量内容由网友产生,如果有内容涉及您的版权或隐私,请点击右下角举报,我们会立即回应和处理。
版权声明:本站也有大量原创,本站欢迎转发原创,但转发前请与本站取得书面合作协议。

Powered by Discuz! X3.4 Copyright © 2003-2020, WinnipegChinese.COM
GMT-5, 2024-10-3 10:24 , Processed in 0.023759 second(s), 25 queries .