urgent help!!
hi
i have this code:
public static void readAccounts(String fileName)
{
String[] lines = LineIO.readAllLines(fileName);
for (String line : lines)
{
String[] a = line.split("&");
{
if(line.startsWith("P")){
account.add(new PrepaidAccount(a[1], a[2], a[3], a[4]));}
}
if(line.startsWith("C")){
account.add(new ContractAccount(b[1], b[2]), b[3], b[4))];}
}
}
and it keeps giving me a error:
cannot find symbol - constructor PrepaidAccount(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
any help?
cheers
# 1
> and it keeps giving me a error:
>
> cannot find symbol - constructor
> PrepaidAccount(java.lang.String, java.lang.String,
> java.lang.String, java.lang.String)
>
> any help?
Yes, your class PrepaidAccount does not have a constructor taking 4 strings.
# 2
> cannot find symbol - constructor> PrepaidAccount(java.lang.String, java.lang.String,> java.lang.String, java.lang.String)> Write a constructor in PrepaidAccount class with 4 string args
# 3
i already have this constructor:
public PrepaidAccount(String prepaid, int balance, int phoneNumber, String customerName)
{
super(phoneNumber, customerName);
this.prepaid = prepaid;
this.balance = balance;
}
do i need to change the ints into strings before it will find it!!
# 4
Use Integer.parseInt instead
if(line.startsWith("P")){
account.add(new PrepaidAccount(a[1], Integer.parseInt(a[2]), Integer.parseInt(a[3]), a[4]));}
}
# 5
da_master_of_nuthin, for future postings:- please use a descriptive subject next time;- please use code tags (see: http://forum.java.sun.com/help.jspa?sec=formatting).Thanks.
# 6
> da_master_of_nuthin, for future postings:
>
> - please use a descriptive subject next time;
> - please use code tags (see:
> http://forum.java.sun.com/help.jspa?sec=formatting).
Also, please consider reading the error messages and occasionally simply trying some things yourself, instead of asking and waiting for someone to tell you what to do.
# 7
> Also, please consider reading the error messages and
> occasionally simply trying some things yourself,
> instead of asking and waiting for someone to tell you
> what to do.
Yes, that too. ; )
But the two I posted were the M0sT URGENT!!1 ones.
# 8
ok fine ill try to do that next time
# 9
> ok fine ill try to do that next timeThank you.
# 10
hi i have tried this, and it still produces an error saying there is a ) missing, could you please help me:
public static void readAccounts(String fileName)
{
String[] lines = LineIO.readAllLines(fileName);
for (String line : lines)
{
String[] a = line.split("&");
{
if(line.startsWith("P")){
PrepaidAccount p = new PrepaidAccount(a[1], Integer.parseInt a[2], Integer.parseInt a[3], a[4]);
account.add(p)
}
if(line.startsWith("C")){
ContractAccount c = new ContractAccount(a[1], Integer.parseInt a[2], Integer.parseInt a[3], Integer.parseInt a[4], Integer.parseInt a[5], Integer.parseInt a[6], a[7]);}
account.add(c);
}
}
# 11
> hi i have tried this, and it still produces an error
> saying there is a ) missing, could you please help
> me:
>
public static void readAccounts(String fileName)
{
String[] lines = LineIO.readAllLines(fileName);
for (String line : lines)
{
String[] a = line.split("&");
{
^
//what's his curly brace doing here? get rid of it!
if(line.startsWith("P")){
PrepaidAccount p = new PrepaidAccount(a[1],
Integer.parseInt a[2], Integer.parseInt a[3],
a[4]);
account.add(p)
^
//The line above needs a semi-colon at the end
if(line.startsWith("C")){
ContractAccount c = new
ContractAccount(a[1], Integer.parseInt a[2],
Integer.parseInt a[3], Integer.parseInt a[4],
Integer.parseInt a[5], Integer.parseInt a[6],
a[7]);}
^
//get rid of this closing curly
account.add(c);
}
~Tim
# 12
Do you know how to call a method?
mlk at 2007-7-7 14:52:14 >
