0

Having an issue on line 192 in netbeans cannot seem to figure out were the issue is

Line 192: System.out.println("Percent off: "+customer.getcustomerDiscount());

Error: 
cannot find symbol
symbol: method getcustomerDiscount()
location: variable customer of type Customer

(PS yes i know it's in 1 java file, it's supposed to be)

package Driver2;

import java.util.Scanner;
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
class Person{
private String name;
private String address;
private String number;
private int customerPurchase;

//Constructors
public Person(String name, String address, String number, int customerPurchase){
    this.name = name;
    this.address = address;
    this.number = number;
    this.customerPurchase = customerPurchase;
}

public Person(){}

//Accessors
public String getName(){
    return this.name;
}

public String getAddress(){
    return this.address;
}

public String getNumber(){
    return this.number;
}

public int getcustomerPurchase(){
    return this.customerPurchase;
}

//Mutators
public void setName(String n){
    this.name = n;
}

public void setAddress(String a){
    this.address = a;
}

public void setNumber(String n){
    this.number = n;
}

public void setcustomerPurchase(int a){
    this.customerPurchase = a;
}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
class Customer extends Person{
private String customerNumber;
private boolean recieveMail;

//Constructors
public Customer(String name, String address, String number, String customerN, boolean rm, int customerPurchase) {
    super(name, address, number, customerPurchase);
    this.customerNumber = customerN;
    this.recieveMail = rm;
}

public Customer(){}

//Accessors
public String getCustomerNumber(){
    return this.customerNumber;
}

public boolean getRecieveMail(){
    return this.recieveMail;
}

//Mutators
public void setCustomerNumber(String c){
    this.customerNumber = c;
}

public void setRecieveMail(boolean r){
    this.recieveMail = r;
}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
class Driver1 extends Customer
{
private int customerPurchase = 0;
private int customerDiscount;

//Constructors
   /* public Driver1(String name, String address, String number, String customerN, boolean rm, int customerPurchase)
{
    super();
    this.customerPurchase = customerPurchase;
    //this.customerDiscount = customerDiscount;
}*/
    public Driver1(String name, String address, String number, String customerN, boolean rm, int customerPurchase) {
    //super(name, address, number, customerPurchase, customerN, rm);
    //this.customerPurchase = customerN;
    //this.customerDiscount = pc;
}

public Driver1()
{}

//Accessors

//@Override
//public int getcustomerPurchase()
//{
//    return this.customerPurchase;
//}

public int getcustomerDiscount()
{
    return this.customerDiscount;
}

//Mutators
/*
@Override
public void setcustomerPurchase(int c)
{
    this.customerPurchase = c;
}*/


public void setcustomerDiscount(int r)
{
    this.customerPurchase = r;
    if (r >= 500)
    {
        System.out.print("5%");
    }
    else if (r >= 1000)
    {
        System.out.print("6%");
    }
    else if (r >= 1500)
    {
        System.out.print("7%");
    }
    else if (r >= 2000)
    {
        System.out.print("10%");
    }
    else
    {
        System.out.print("");
    }
}
}
///////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////
class Driver3
{

public static void main(String args[]){

    Scanner scanner = new Scanner(System.in);

    System.out.print("Enter name of customer:");
    String name1 = scanner.nextLine();
    System.out.print("Enter address of customer:");
    String address1 = scanner.nextLine();
    System.out.print("Enter phone number of customer:");
    String number1 = scanner.nextLine();
    System.out.print("Enter customer number:");
    String customerNumber = scanner.nextLine();
    System.out.print("Enter yes/no -- does the customer want to recieve mail?:");
    String answer = scanner.nextLine();
    boolean recieveMail = (answer.equals("yes"));
    System.out.print("Enter amount customer has spent:");
    int customerPurchase = scanner.nextInt();

    Customer customer = new Customer(name1, address1, number1, customerNumber, recieveMail, customerPurchase);

    System.out.println("\nCustomer: ");
    System.out.println("Name: "+customer.getName());
    System.out.println("Address: "+customer.getAddress());
    System.out.println("Phone Number: "+customer.getNumber());
    System.out.println("Customer Number: "+customer.getCustomerNumber());
    System.out.println("Recieve Mail?: "+customer.getRecieveMail());
    System.out.println("Amount Purchased: "+customer.getcustomerPurchase());
    System.out.println("Percent off:  "+customer.getcustomerDiscount());

}
}

Additional I am a little confused, i called the driver 1 and even made an object and couldent get it to work also another question popped up when i tested the if else statement another way

Question Should i leave the if else statement inside the setter? or put into the getter? i think i have an issue were i am not retrieving a string because it is all set as a INT

blackstar
  • 25
  • 6

1 Answers1

2

You are trying to call getcustomerDiscount on a Customer object. The method is not defined on this class but on Driver1.

Also: You should try to use Java naming conventions, in this case getcustomerDiscount and setcustomerDiscount should be renamed to getCustomerDiscount and setCustomerDiscount respectively.

Jan Held
  • 634
  • 4
  • 14