JAVA Hello i am getting a few errors in my code: Customer.java package Cust; /*
ID: 3745338 • Letter: J
Question
JAVA
Hello i am getting a few errors in my code:
Customer.java
package Cust;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author MrMarkycoolsuper
*/
import java.util.ArrayList;
public class Customer {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
}
private String CustID;
private String CustName;
private String CustEmail;
private boolean isPreferred;
public Customer(){}
public Customer(String id, String n, String e, boolean p){
CustID = id;
CustName = n;
CustEmail = e;
isPreferred = p;
}
/**
* @return the CustID
*/
public String getCustID() {
return CustID;
}
/**
* @param CustID the CustID to set
*/
public void setCustID(String CustID) {
this.CustID = CustID;
}
/**
* @return the CustName
*/
public String getCustName() {
return CustName;
}
/**
* @param CustName the CustName to set
*/
public void setCustName(String CustName) {
this.CustName = CustName;
}
/**
* @return the CustEmail
*/
public String getCustEmail() {
return CustEmail;
}
/**
* @param CustEmail the CustEmail to set
*/
public void setCustEmail(String CustEmail) {
this.CustEmail = CustEmail;
}
/**
* @return the isPreferred
*/
public boolean isIsPreferred() {
return isPreferred;
}
/**
* @param isPreferred the isPreferred to set
*/
public void setIsPreferred(boolean isPreferred) {
this.isPreferred = isPreferred;
}
ArrayList<Customer>allCustomers=new ArrayList<>();
allCustomers.add(new Customer("1234","Dawn Patitucci","patitucci@morainevally.edu",false));
allCustomers.add(new Customer("5678","Fred Flintstone","flintstone@gma.com",false));
allCustomers.add(new Customer("9012","Hello Kitty","hello_ketty@gma.com",false));
allCustomers.add(new PreferredCustomer("3456","Marcia Drady","marcia_Drady@gma.com",true,25,1000));
allCustomers.add(new PreferredCustomer("7890","Abraham Lincon","pres_lincon@gm.com",true,50,2000));
System.out.println("ID CUSTOMER NAME EMAIL ADDRESS PREFERRED?");
System.out.println("------------------------------------------------------------------------------");
for (Customer allCustomer : allCustomers) {
System.out.println(allCustomer);
}
}
@Override
public String toString()
{
String pre;
if(isPreferred)
pre="Yes";
else
pre="No";
return String.format("%1$-8s", CustID)+
String.format("%1$-25s", CustName)+
String.format("%1$-35s", CustEmail)+
String.format("%1$-10s", pre);
}
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Cust;
/**
*
* @author MrMarkycoolsuper
*/
public class PreferredCustomer extends Customer {
private double discount;
private int points;
public PreferredCustomer(){}
public PreferredCustomer (String id, String n, String e, boolean p,double discount,int points){
}
super(id,n,e,p);
this.discount=getDiscount;
this.points=getPoints;
/**
* @return the discount
*/
public double getDiscount() {
return discount;
}
/**
* @param discount the discount to set
*/
public void setDiscount(double discount) {
this.discount = discount;
}
/**
* @return the points
*/
public int getPoints() {
return points;
}
/**
* @param points the points to set
*/
public void setPoints(int points) {
this.points = points;
}
@Override
public String toString()
{
return (super.toString()+" PREFERRED DISCOUNT RATE: " +this.discount+"% REWARD POINTS:"+this.points)
}
}
PreferredCustomer.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Cust;
/**
*
* @author MrMarkycoolsuper
*/
public class PreferredCustomer extends Customer {
private double discount;
private int points;
public PreferredCustomer(){}
public PreferredCustomer (String id, String n, String e, boolean p,double discount,int points){
}
super(id,n,e,p);
this.discount=getDiscount;
this.points=getPoints;
/**
* @return the discount
*/
public double getDiscount() {
return discount;
}
/**
* @param discount the discount to set
*/
public void setDiscount(double discount) {
this.discount = discount;
}
/**
* @return the points
*/
public int getPoints() {
return points;
}
/**
* @param points the points to set
*/
public void setPoints(int points) {
this.points = points;
}
@Override
public String toString()
{
return (super.toString()+" PREFERRED DISCOUNT RATE: " +this.discount+"% REWARD POINTS:"+this.points)
}
}
Explanation / Answer
PreferredCustomer.java
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package Cust;
/**
*
* @author MrMarkycoolsuper
*/
public class PreferredCustomer extends Customer {
private double discount;
private int points;
public PreferredCustomer(){}
public PreferredCustomer (String id, String n, String e, boolean p,double discount,int points){
super(id,n,e,p);
this.discount=discount;
this.points=points;
}
/**
* @return the discount
*/
public double getDiscount() {
return discount;
}
/**
* @param discount the discount to set
*/
public void setDiscount(double discount) {
this.discount = discount;
}
/**
* @return the points
*/
public int getPoints() {
return points;
}
/**
* @param points the points to set
*/
public void setPoints(int points) {
this.points = points;
}
@Override
public String toString()
{
return (super.toString()+" PREFERRED DISCOUNT RATE: " +this.discount+"% REWARD POINTS:"+this.points);
}
}
Customer.java
package Cust;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author MrMarkycoolsuper
*/
import java.util.ArrayList;
public class Customer {
/**
* @param args the command line arguments
*/
private String CustID;
private String CustName;
private String CustEmail;
private boolean isPreferred;
public Customer(){}
public Customer(String id, String n, String e, boolean p){
CustID = id;
CustName = n;
CustEmail = e;
isPreferred = p;
}
/**
* @return the CustID
*/
public String getCustID() {
return CustID;
}
/**
* @param CustID the CustID to set
*/
public void setCustID(String CustID) {
this.CustID = CustID;
}
/**
* @return the CustName
*/
public String getCustName() {
return CustName;
}
/**
* @param CustName the CustName to set
*/
public void setCustName(String CustName) {
this.CustName = CustName;
}
/**
* @return the CustEmail
*/
public String getCustEmail() {
return CustEmail;
}
/**
* @param CustEmail the CustEmail to set
*/
public void setCustEmail(String CustEmail) {
this.CustEmail = CustEmail;
}
/**
* @return the isPreferred
*/
public boolean isIsPreferred() {
return isPreferred;
}
/**
* @param isPreferred the isPreferred to set
*/
public void setIsPreferred(boolean isPreferred) {
this.isPreferred = isPreferred;
}
public static void main(String[] args) {
// TODO code application logic here
ArrayList<Customer> allCustomers = new ArrayList<>();
allCustomers.add(new Customer("1234","DawnPatitucci","patitucci@morainevally.edu",false));
allCustomers.add(new Customer("5678","Fred Flintstone","flintstone@gma.com",false));
allCustomers.add(new Customer("9012","Hello Kitty","hello_ketty@gma.com",false));
allCustomers.add(new PreferredCustomer("3456","MarciaDrady","marcia_Drady@gma.com",true,25,1000));
allCustomers.add(new PreferredCustomer("7890","Abraham Lincon","pres_lincon@gm.com",true,50,2000));
System.out.println("ID CUSTOMER NAME EMAIL ADDRESS PREFERRED?");
System.out.println("------------------------------------------------------------------------------");
for (Customer allCustomer : allCustomers) {
System.out.println(allCustomer);
}
}
@Override
public String toString()
{
String pre;
if(isPreferred)
pre="Yes";
else
pre="No";
return String.format("%1$-8s", CustID)+
String.format("%1$-25s", CustName)+
String.format("%1$-35s", CustEmail)+
String.format("%1$-10s", pre);
}
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.