I try to set a variable in another class. It does not. It goes to that class and the variable is always 0and the program stops. I know its something basic that I should know but I need it to set the variable and continue in the calling class. Any Help?

package creditcard;
//Credit Card Test - tests CreditCard class

/*
 Debit or Credit transaction (1=Debit, 2=Credit, 0=Exit): 1
 
Transaction (0=no transaction, +=deposit, -=new charge, -1=Display Logs): -15
 
Transaction Description: Daily Parking
 
 */
import java.io.File;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.sql.SQLException;
import creditcard.CreditCard.*;
import tio.*;

class CreditCardTest {
    private DebitCard dc;
    private CreditCard cc;
    int hold =0;
    
    public static void main(String[] args) throws IOException, SQLException, Exception {
        new CreditCardTest();
    }
    public CreditCardTest() throws IOException, SQLException, Exception{
        String f = "CC_Num_status.txt";
        File file = new File(f);
        FormattedWriter fw=new FormattedWriter(f);
        System.out.println("Welcome to the Credit Card simulator!");
        System.out.println("Debit or Credit transaction (1=Debit, 2=Credit, 0=Exit): ");
       
            CreditCard cc = new CreditCard();
            cc.setAcctTypeCode(Console.in.readInt());

...............continued---------------->

Recommended Answers

All 2 Replies

Member Avatar for iamthwee

What? Is that your entire code?

+ which variable u r trying to change?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.