Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes these values and the appropriate mutator and accessor methods for the class's fields. Demonstrate the Customer class in a program that prompts the user to enter values for the customer's name, address, phone number, and customer number, and then asks the user whether or not the customer wants to receive mail. Use this information to create a customer object and then print its information. Put all of your classes in the same file. To do this, do not declare them public.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 2PE
icon
Related questions
Question

java

Design a class named Person with fields for holding a person's name, address, and telephone number
(all as Strings). Write a constructor that initializes all of these values, and mutator and accessor
methods for every field.
Next, design a class named Customer, which inherits from the Person class. The Customer class
should have a String field for the customer number and a boolean field indicating whether the
customer wishes to be on a mailing list. Write a constructor that initializes these values and the
appropriate mutator and accessor methods for the class's fields.
Demonstrate the Customer class in a program that prompts the user to enter values for the customer's
name, address, phone number, and customer number, and then asks the user whether or not the
customer wants to receive mail. Use this information to create a customer object and then print its
information.
Put all of your classes in the same file. To do this, do not declare them public.
Instead, simply write:
class Person {
}
class Customer {
}
...
...
Sample Run
java Driver
Enter name·of•customer:Julia Stevens-
Enter·address of customer:77.Massachusetts·Ave Cambridge, ·MA · 02139-
Enter phone·number·of·customer:617-777–7777-
Enter customer:number:928734502
Enter yes/no·--•does·the customer:want to receive mail?:no-
Customer:·d
Name: Julia Stevens-
Address: 77 · Massachusetts Ave Cambridge, MA·02139
Phone Number::617-777-7777-
Customer Number:·928734502-
Receive Mail?:·false-
Transcribed Image Text:Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a constructor that initializes all of these values, and mutator and accessor methods for every field. Next, design a class named Customer, which inherits from the Person class. The Customer class should have a String field for the customer number and a boolean field indicating whether the customer wishes to be on a mailing list. Write a constructor that initializes these values and the appropriate mutator and accessor methods for the class's fields. Demonstrate the Customer class in a program that prompts the user to enter values for the customer's name, address, phone number, and customer number, and then asks the user whether or not the customer wants to receive mail. Use this information to create a customer object and then print its information. Put all of your classes in the same file. To do this, do not declare them public. Instead, simply write: class Person { } class Customer { } ... ... Sample Run java Driver Enter name·of•customer:Julia Stevens- Enter·address of customer:77.Massachusetts·Ave Cambridge, ·MA · 02139- Enter phone·number·of·customer:617-777–7777- Enter customer:number:928734502 Enter yes/no·--•does·the customer:want to receive mail?:no- Customer:·d Name: Julia Stevens- Address: 77 · Massachusetts Ave Cambridge, MA·02139 Phone Number::617-777-7777- Customer Number:·928734502- Receive Mail?:·false-
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT