Customer

Customer - { return cashAmount; } // The next four methods...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// Assignment #: 8 // Name: Your name // StudentID: Your id // Lab Lecture: Your lecture // Description: The Customer class describes a customer entity and contains // attributes first name, last name, customer ID, and cash amount. // It also contains the accessors and the modifiers of each attribute. import java.text.*; public class Customer { private String firstName; private String lastName; private String customerID; private double cashAmount; // constructor method to initialize each instance variable. public Customer() { firstName = new String("?"); lastName = new String("?"); customerID = new String("?"); cashAmount = 0.0; } // The next four methods are accessor method for // each instance variable. public String getFirstName() { return firstName; } public String getLastName() { return lastName; } public String getCustomerID() { return customerID; } public double getCashAmount()
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: { return cashAmount; } // The next four methods are mutator methods for // each instance variable. public void setFirstName(String fname) { firstName = fname; } public void setLastName(String lname) { lastName = lname; } public void setCustomerID(String custId) { customerID = custId; } public void setCashAmount(double cash) { cashAmount = cash; } // The toString method returns a string describing // the value of each instance variable. public String toString() { String customerString; NumberFormat fmt = NumberFormat.getCurrencyInstance(); customerString = "\nFirst name:\t\t" + firstName + "\n" + "Last name:\t\t" + lastName + "\n" + "Customer ID:\t\t" + customerID + "\n" + "Cash amount:\t\t" + fmt.format(cashAmount) + "\n\n"; return customerString; } } // end of Customer class...
View Full Document

This note was uploaded on 11/09/2010 for the course CSE 71682 taught by Professor Nakamura during the Spring '10 term at ASU.

Page1 / 2

Customer - { return cashAmount; } // The next four methods...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online