how to store item and invoke from it

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Sep 2005
Posts: 3
Reputation: katew is an unknown quantity at this point 
Solved Threads: 0
katew katew is offline Offline
Newbie Poster

how to store item and invoke from it

 
0
  #1
Sep 13th, 2005
i am having a problem to store the item and call from it.It is like you already created a text file,then you need to assess item from it.the item is in disorder.
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 902
Reputation: chrisbliss18 is an unknown quantity at this point 
Solved Threads: 23
chrisbliss18's Avatar
chrisbliss18 chrisbliss18 is offline Offline
Posting Shark

Re: how to store item and invoke from it

 
0
  #2
Sep 13th, 2005
I don't know what you are asking for. Can you clarify?

Can you show an example of what you are trying to do and what problem you are having with getting it to work?

It also helps if you ask specific questions.
Did we help you? Did we miss the point entirely? Update your thread and let us know.
Don't like the answers you are getting?
Did you try searching?
Clean up and optimize Windows 2000/XP
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 3
Reputation: katew is an unknown quantity at this point 
Solved Threads: 0
katew katew is offline Offline
Newbie Poster

Re: how to store item and invoke from it

 
0
  #3
Sep 14th, 2005
while (line!=null)
{


tokens = new StringTokenizer(line, ",",false);
String assessNameToken = tokens.nextToken();
if((tokens.hasMoreTokens()) );
int maxScoreToken = Integer.parseInt(tokens.nextToken());
int scaleScoreToken = Integer.parseInt(tokens.nextToken());

descript[size] = new Assessment(assessNameToken, maxScoreToken, scaleScoreToken);
size++;
line = readDescription.readLine();

}

is almost like tat..i wanted to read the string file...but i dont think it can uses the parseString..i wanted to store into an array and called it afterward for further use...i dunno whether i make the question clear o not??
Reply With Quote Quick reply to this message  
Join Date: May 2005
Posts: 55
Reputation: NPH is an unknown quantity at this point 
Solved Threads: 1
NPH NPH is offline Offline
Junior Poster in Training

Re: how to store item and invoke from it

 
0
  #4
Sep 14th, 2005
Firstly,

The line with the code
  1. if((tokens.hasMoreTokens()) );
is basically useless. This checks if there are tokens and does nothing. What you want is
  1. if((tokens.hasMoreTokens()) )
  2. {
  3. //put code here
  4. }
Also, you might want to use the trim() function when getting tokens. This cleans out the string of weird spaces at the beginning and end:
  1. String someTokenHere = tokens.nextToken().trim();
For more help, www.NeedProgrammingHelp.com
Reply With Quote Quick reply to this message  
Join Date: Sep 2005
Posts: 3
Reputation: katew is an unknown quantity at this point 
Solved Threads: 0
katew katew is offline Offline
Newbie Poster

Re: how to store item and invoke from it

 
0
  #5
Sep 14th, 2005
import java.io.*;
import java.util.*;

public class try2
{
public static void main(String[] args)
{
Assessment[] result= new Assessment[10];

String line,line1, subjectName,token;
int lineNum=0;
int size=0;
int time=0;

try
{

BufferedReader readResult= new BufferedReader(new FileReader("ResultFile.txt."));


subjectName = readResult.readLine();


line = readResult.readLine();


StringTokenizer tokens;

while (line!=null)
{


tokens = new StringTokenizer(line, ",",false);
String studentIdToken = tokens.nextToken();
if(tokens.hasMoreTokens() );
String studentToken = tokens.nextToken();
String assessmentItemToken = tokens.nextToken();
double assessmentMarkToken = Double.parseDouble(tokens.nextToken());

result[size] = new Assessment(studentIdToken, studentToken, assessmentItemToken,assessmentMarkToken);
size++;
line = readResult.readLine();

}
System.out.println(subjectName); // check whether the infomation have been stored
System.out.println(result[2].getStudentId());
System.out.println(result[3].getStudent());
System.out.println(result[4].getAssessmentItem());
System.out.println(result[4].getAssessmentMark());


}


catch(FileNotFoundException e)
{
System.err.println("file not found");
}

catch(IOException e)
{
System.err.println(e);
}
}

}

class Assessment
{
private String student, assessmentItem;
private int studentId;
private double assessmentMark;

public Assessment(String name,String item, int id, double mark)
{
student=name;
assessmentItem=item;
studentId=id;
assessmentMark=mark;
}


public double getAssessmentMark()
{
return assessmentMark;
}

public int getStudentId()
{
return studentId;
}

public String getAssessmentItem()
{
return assessmentItem;
}

public String getStudent()
{
return student;
}

}



i still dunno wat happen to my program..it says tat cannot find the symbol constructor.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC