Question: JAVA LANGUAGE 7. Person and Customer Classes Design a class named Person with fields for holding a persons name, address, and telephone number. Write one

JAVA LANGUAGE

7. Person and Customer Classes

Design a class named Person with fields for holding a persons name, address, and telephone number. Write one or more constructors and the appropriate mutator and accessor methods for the classs fields.

Next, design a class named Customer, which extends the Person class. The Customer class should have a field for a customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write one or more constructors and the appropriate mutator and accessor methods for the classs fields. Demonstrate an object of the Customer class in a simple program.

**************THIS NEXT VERSION IS THE MODIFICATIONS FOR MY CLASS**************

Do a MODIFIED VERSION of Programming Challenge #7(Person and Customer classes) at the end of Chapter 10 (p. 700). REQUIRED additions to the programming challenge #7:

1) Add an "age" field to the Person class with appropriate methods to get and set the age.

2) Add an interface (you can call it what you want but a good suggestion would be "AgeCalculator")

This interface will be similar to the IntCalculator in book (p.686) EXCEPT this will have a calculate method that takes 2 parameters instead of 1.

3) Create a Lambda Expression with 2 Parameters .... see "Lambda Expressions with Multiple Parameters" on p. 689 . In the book they called their calculate method with 1 parameter (num) but you will be calling yours with 2 parameters -- the person's current age which is stored in the Person/Customer object and how many years you want to add to that person's age .

Example : ask the user how many years they want to add to the person's age and say you store it in a variable called futureAge ; assuming you defined your multiple parameter lambda expression (let's say you called it future) and your AgeCalculator interface, you could calculate the future age by saying:

future.calculate(curAge, numYearsAdded) (see page 688 for 1 parameter lambda expression call)

**********LAMBDA EXPRESSIONS FOR FINAL QUESTION*************

Lambda Expressions with Multiple Parameters

If a functional interfaces abstract method has multiple parameters, any lambda expression that you use with the interface must also have multiple parameters. To use more than one parameter in a lambda expression, simply write a comma-separated list and enclose the list in parentheses. Here is an example:

(a, b) > a + b;

This lambda expression has two parameters, a and b. The expression returns the value of a + b.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!