-
January 14th, 2004, 06:16 PM
#1
Senior Member
Some java help...a little stuck
I was wondering if someone here could try and help me with something. I have a programming project that requires me to input a text file, determine what kind of record it is ( such as add or ship ) then store the data types in an object. I have a couple problems that i run into.
If the line starts with A 7 different data types need to be constructed in an add class
If the line starts with S 4 integers need to be sent to the Ship class constructor
a typical line for add in the input file would be as follows: A 9999 C 2.3 2 0 1 3
and for ship : S 1 0 2 4
in the main i initiate a loop so i can read in using bufferedreadline
public class InputMain
{
public static void main(String[] args)
throws IOException
{
BufferedReader console = new BufferedReader(new InputStreamReader(System.in));
String lastline = "";
char addA = "a";
boolean done = false;
while(!done)
{
String input = console.readline();
char ch = Character.toLowerCase(s.CharAt(0));
//checks first letter
if ( input == null)
done = true;
//i am not sure of the syntax to fine out what the record is
else if ( input.indexOf(ch) == addA )
//also i dont understand how to break up the full string into parts using substring
//i assume i should pass all as strings and parse them in a method of add
Add Adding = new Add( int , char , double , int , int , int , int);
else
Ship Shipping = new Ship(int , int , int , int );
//ends snip of code
what i dont understand isexactly how to compare the first charactar of the string and how to break it up into multiple strings using a space a the divider.
The examples in my book are not clear on this and have maybe devoted a half of a page to the subject. I've done a couple of searches and have come up empty. Any help would be appreciated.
Ben Franklin said it best. \"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.\"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|