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
PLSSSSSS HELP ASAP<br><br> What story does the game Senet tell?
kkurt [141]

Answer:

In the New Kingdom, the game senet, which means "passing," became associated with the journey to the afterlife. Some of the squares of the game corresponded to the hazards a person might meet on their journey to the afterlife, while other squares helped the players.

Explanation:

8 0
3 years ago
Read 2 more answers
Three reasons why users attach speakers to their computers.
ZanzabumX [31]

Answer:

Iv'e answered this question 2 times already lol. The purpose of speakers is to produce audio output that can be heard by the listener. Speakers are transducers that convert electromagnetic waves into sound waves. The speakers receive audio input from a device such as a computer or an audio receiver.

Explanation: I hope this helps!

8 0
3 years ago
17. Ano ang tawag sa pahina ng Excel?
kompoz [17]

D

Explanation:

D.spread sheet

........,,............:-)

5 0
3 years ago
Your users are reporting latency in your services. Traditionally with on premise architecture, you would have to page your admin
liq [111]

Answer:

You have to enable the Amazon CloudWatch alarm that would trigger the scaling policy.

Explanation:

Amazon web service is a cloud-based service company that provides network and database solutions to its customers. Network administrations used these services to enhance productivity and automate their cloud tasks.

The Amazon CloudWatch alarm is a service used by administrators to trigger scaling policies for their deployed applications and tasks.

6 0
3 years ago
g Returns the contents of the list as a new array, with elements in the same order they appear in the list. The length of the ar
natali 33 [55]

Answer:

Find the attached picture

Explanation:

Attached picture contains the Python function which takes a list as argument and returns a new list with same size and elements in same order.

3 0
3 years ago
Other questions:
  • A device that produces a permanent human-readable text of graphic document.
    15·1 answer
  • What specific database stores local user accounts on local computers, and allows users to sign in to and access resources only o
    9·1 answer
  • 2(x-5)-3(3-x)=1/2(x-2)
    9·1 answer
  • Daniel owns a construction company that builds homes. To help his customers visualize the types of homes he can build for them,
    6·1 answer
  • A_______is a limitation imposed on the engineer. It can be a limitation on
    5·1 answer
  • What specific record type is found in every zone and contains information that identifies the server primarily responsible for t
    10·1 answer
  • Which of these functions may be used with positional arguments? Select four options.
    10·1 answer
  • Help<br> pls need quickly
    9·1 answer
  • An editing functions used to move selected text or objects to the Clipboard, from which they may be pasted elsewhere in the pres
    9·1 answer
  • Select the correct answer.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!