Hi,
I am struggling to finish off my java program and cannoy solve the errors i am getting. I have two classes left that i am struggling with an would really appriciate any help i would get.
Class ~ Customer (inherits Person)
This class describes an object representing one customer, obtaining some of its attributes and methods from its super-class.
customerPoints has neither a set method nor a get method. It is accessed solely within the Customer class.
Customer()
Initialises string attributes as empty strings.
Customer(firstName : String, surname : String, phoneNo : String, email: String)
Initialises attributes from parameters where appropriate, creates a new PointsRecord object.
addPoints(saleValue : double, category : int) : int
Calls the addPoints(double, int) method in the customer's PointsRecord object and passes the parameters on to that method. The value (representing points added) passed back from that method is returned from this method.
redeemPoints(points : int) : int
Calls the redeemPoints method in PointsRecord, passing the number of points. The value returned by that method is passed back from this method. Note that a return of -1 indicates that the redemption was unsuccessful.
getLifetimePoints() : int
Calls the corresponding method in PointsRecord to find out the total points earned throughout the customer's membership.
getCurrentPoints() : int
Calls the corresponding method in PointsRecord to find out the current points held by the customer.
Class ~ CustomerList
Holds a collection of customers who are registered with the loyalty scheme. It has an ArrayList of Customer objects. The ArrayList has neither a set method nor a get method.
It has three publicly-available class constants.
CustomerList()
Initialises the list by creating a new empty ArrayList<Customer>object.
getCustomerNames() : String[ ]
Creates a string array containing the full name of each customer.
getCustomerAt(index : int) : Customer
Uses the int parameter to retrieve the customer at the given location in the list. The Customer object is returned.
addCustomer(customer : Customer) : void
Adds a new Customer object to the end of the list.
removeCustomerAt(index : int) : int
Deletes the customer at the position given by the parameter, but only if the customer has a zero points total. The return value can be 0, 1 or 2:
0 indicates that the deletion was successful,
1 indicates that the index was out of range, and
2 indicates that the customer was not deleted because their points total is not zero.
The class constants reflect these outcomes.
getTotalPoints() : int
Iterates through the list of customers summing the total points in order to find out the company's total points liability.
size() : int
Returns the number of customers in the list.
This is the code i have written myself for the both and it needs sorting
Customer class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package loyaltyscheme;
/**
*
* @author Warbie
*/
public class Customer extends Person {
private PointsRecord customerPoints;
public Customer() {
firstName = "";
surname = "";
phoneNo = "";
}
public Customer(String firstName, String surname, String phoneNo, String email) {
this.firstName = firstName;
this.surname = surname;
this.phoneNo = phoneNo;
this.emailAddress = new EmailAddress(email);
this.customerPoints = new PointsRecord();
}
public int addPoints(double saleValue, int category){
return addPoints(saleValue,category) ;
}
public int redeemPoints(int points) {
return redeemPoints(points);
}
public int getLifetimePoints () {
return getLifetimePoints();
}
public int getCurrentPoints() {
return getCurrentPoints();
}
@Override
public String toString() {
return "Customer{" + "customerPoints=" + customerPoints + '}';
}
}
CustomerList class
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package loyaltyscheme;
/**
*
* @author Warbie
*/
import java.util.ArrayList;
public class CustomerList {
private ArrayList<Customer> list;
public static int CUSTOMERDELETED = 0;
public static int INVALIDINDEX = 1;
public static int POINTSNOTZERO = 2;
public CustomerList() {
list = new ArrayList<Customer>();
}
public CustomerList(ArrayList<Customer> list) {
this.list = list;
}
public String[] getCustomerNames(){
String[] names = new String[list.size()];
int ct = 0;
for (Customer customer:list) {
names[ct] = customer.getFullName();
ct ++;
}
return names;
}
public Customer getCustomerAt (int index) {
if (index < 0 || index > list.size())
return null;
else
return list.get(index);
}
public void addCustomer(Customer customer) {
list.add (customer);
}
public int removeCustomerAt(int index) {
if (index < 0 || index > list.size())
return INVALIDINDEX;
else if (customerPoints > 0)
return POINTSNOTZERO;
else
return CUSTOMERDELETED;
}
public int getTotalPoints() {
return
}
public int size() {
return list.size();
}
}
Would really appriciate any help!!
Thank you