Hello friends,

I am new to java and enum use. Actually I need to give only 3 options to customer for Payment Type. So i thought of using enum and making the limited members of Payment

enum PaymentType 
{
CHEQUE,
CREDITCARD,
CASH
};

public void Customer(String name, PaymentType paymentType)
{
//select which paymentType he opted
}

but i dont know how to implement enum for making option like that. please can anyone guide me.

public void Customer(String name, PaymentType paymentType) {
    //select which paymentType he opted
        switch (paymentType) {
            case CHEQUE:  // enumeration constant, wrong is use PaymentType.CHEQUE
                //
                break;
            case CREDITCARD:
                //
                break;
            case CASH:
                // 
                break;
        }
    }

The Java Tutorials is your first book!
http://download.oracle.com/javase/tutorial/java/javaOO/enum.html

But how do i pass PaymentType argument When there's no object is created.

Customer("John", PaymentType.CHEQUE);
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.