1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
12345 [234]
3 years ago
15

Design a class named Person with fields for holding a person's name, address, and telephone number (all as Strings). Write a con

structor 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.
Computers and Technology
1 answer:
Sophie [7]3 years ago
7 0

Answer:

Explanation:

The following code is written in Java. It creates the three classes as requested with the correct constructors, and getter/setter methods. Then the test class asks the user for all the information and creates the customer object, finally printing out that information from the object getter methods.

import java.util.Scanner;

class Person {

   String name, address, telephone;

   private void Person (String name, String address, String telephone) {

       this.name = name;

       this.address = address;

       this.telephone = telephone;

   }

   public String getName() {

       return name;

   }

   public void setName(String name) {

       this.name = name;

   }

   public String getAddress() {

       return address;

   }

   public void setAddress(String address) {

       this.address = address;

   }

   public String getTelephone() {

       return telephone;

   }

   public void setTelephone(String telephone) {

       this.telephone = telephone;

   }

}

class Customer extends Person {

   String customerNumber;

   Boolean mailingList;

   public Customer(String s, Boolean mail) {

       super();

       this.customerNumber = customerNumber;

       this.mailingList = mailingList;

   }

   public String getCustomerNumber() {

       return customerNumber;

   }

   public void setCustomerNumber(String customerNumber) {

       this.customerNumber = customerNumber;

   }

   public Boolean getMailingList() {

       return mailingList;

   }

   public void setMailingList(Boolean mailingList) {

       this.mailingList = mailingList;

   }

}

class Test {

   public static void main(final String[] args) {

       Scanner in = new Scanner(System.in);

       System.out.println("Enter Customer Name: ");

       String name = in.nextLine();

       System.out.println("Enter Customer Address: ");

       String address = in.nextLine();

       System.out.println("Enter Customer Telephone: ");

       String telephone = in.nextLine();

       System.out.println("Would you like to receive mail? y/n ");

       Boolean mail;

       if(in.nextLine() == "y") {

           mail = true;

       } else {

           mail = false;

       }

       Customer customer = new Customer("1", mail);

       customer.setName(name);

       customer.setAddress(address);

       customer.setTelephone(telephone);

       System.out.println("Name: " + customer.getName());

       System.out.println("Address: " + customer.getAddress());

       System.out.println("Telephone: " + customer.getTelephone());

       System.out.println("Wants to receive mail: " + String.valueOf(customer.getMailingList()));

   }

}

You might be interested in
Question 2/21
chubhunter [2.5K]

Answer:

True.

Explanation:

Bau team is struggling to complete their daily BAU work. If they look for another task which is Value Maximization Scrum then they will loose focus from the BAU work. The team will be confused between two tasks and will not be able to meet either commitments. It is better for them to focus on initial task only.

4 0
3 years ago
The combination of two or more technologies or data feeds into a single, integrated tool is referred to as a _____.
igomit [66]
Mash-up, I believe, is the correct answer.
5 0
2 years ago
Which are among the ways you can use bitlocker encryption? (choose all that apply?
igor_vitrenko [27]
There is a lot of ways that you can use the bit locker encryption. Some are when you are authenticating your computer using a TPM. Or when you are authenticating your account using a USB Flash drive, and most on the phones authentication through text messages and all.
3 0
3 years ago
the term elastic in ec2 refers to the fact that you can easily increase or decrease the number of servers you run to support an
Dvinal [7]

The phrase "elastic" refers to the ability of a user to construct, launch, and terminate server instances as needed while paying per second for active servers.

By giving users control over the physical location of instances, EC2 enables users to reduce latency and increase redundancy. the capacity to acquire resources as needed and to release resources as required. You want to carry out this task automatically in the cloud. Even if an instance becomes ill or based on criteria you specify, Amazon EC2 Auto Scaling will automatically adjust the number of instances in the group to maintain a fixed number of instances.

Learn more about server here-

brainly.com/question/14307521

#SPJ4

6 0
11 months ago
True and False(Total points: 10)
Gwar [14]

Answer:

1.T 2.f 3.t 4.f 5.f 6.f 7.t 8.t 9.f

8 0
2 years ago
Read 2 more answers
Other questions:
  • HELLLLLP ill make you brainiest and ill give u a lot of points if you HELP ME Directions Part One.
    12·2 answers
  • 11.
    11·1 answer
  • Businesses have taken advantage of many of the smart phone features to promote their business. TRUE OR FALSE
    5·2 answers
  • Schools are businesses that need to install software on a large number of computers can usually obtain a ______
    13·1 answer
  • What is the 7 X 7 when referring to PowerPoint presentations?
    12·2 answers
  • ____ is an object-oriented programming language from Sun Microsystems which allows small programs called applets to be embedded
    13·1 answer
  • Expressing your needs to others is aggressive behavior.<br> True or False?
    5·2 answers
  • Which of the following is NOT a web browser?<br> Safari<br> Chrome<br> Bing<br> Firefox
    8·2 answers
  • Put the following five steps in the order in which you would perform them to use the Paste Special function. 1. Select and copy
    6·1 answer
  • What is 3x10? PLZZZZZ
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!