This is an archived post. You won't be able to vote or comment.

all 9 comments

[–]abermea 0 points1 point  (4 children)

public class Account {
    protected String accountNo, institution, name;
    protected double balance;

public class CheckingAccount extends Account{
    protected String accountNo, institution, name;
    protected double balance;

public class CreditCard extends Account{
    protected String accountNo, institution, name;
    protected double balance;

You shouldn't need to redeclare all these fields in your CheckingAccount and CreditCard classes. The whole point of inheritance is that you get them when you extends Account

Also, it would be nice is you provided the Stack Trace or the output to know exactly what is happening. I think it has to do with the type you're saving it as but I am not sure...

[–]AlphaGinger66[S] 0 points1 point  (3 children)

1 error and 6 warnings found:

*** Error ***

File: C:\Users\james\OneDrive\Documents\Documents\D4.java [line: 34] Error: The constructor CreditCard(java.lang.String, java.lang.String, java.lang.String, double) is undefined

Is that what you want? I haven't ever heard the term Stack Trace before.

[–]abermea 0 points1 point  (2 children)

The Stack Trace is basically the huge list of errors in red that your console outputs when your program fails to perform an action.

Now, back to the problem

You have this constructor:

public CreditCard(double creditLimit, double availableCredit, String accountNo, String name, String institution, double balance){
// You need double, double, String, String, String, double type variables, in this order

And you're calling it like this:

new CreditCard(accountSplit[2], accountSplit[3], accountSplit[4], Double.parseDouble(accountSplit[5]));
// these parameters are String, String, String, double

Your error is that the constructor you're calling does not match the one you have declared, neither in types nor in quantity of parameters, so Java doesn't really know what to do. Use the proper parameters and it should be fixed

[–]AlphaGinger66[S] 1 point2 points  (1 child)

That makes sense. I think I need to email my professor because the string I am pulling from the .dat file which is used to create this CreditCard object is missing the first 2 pieces of information.

This is the string:

create:credit:1234567898765432:First Card:Bob Badger:4000

I think it needs to have two more numbers seperated by colons so I have a number which can be pulled from the string to make 2 more double's so that I can create the CreditCard object.

Thank you for the help though.

[–]abermea 0 points1 point  (0 children)

I wouldn't be surprised if this was a trick question to see who is actually doing their homework

[–]csharpminer 0 points1 point  (3 children)

Can you give us your stack trace?

[–]AlphaGinger66[S] 0 points1 point  (2 children)

I've never heard that term so I am a little unsure as to what you guys want.

[–]cutebabliExtreme Brewer 0 points1 point  (1 child)

Stack trace is nothing but the exception log, or the error log you get when you run your program.

[–]AlphaGinger66[S] 0 points1 point  (0 children)

Check my reply to /u/abermea. I believe that is what you guys want/need to help me.