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
Myles is studying a system to lessen the number of complaints about the Help Desk. He has formally studied the service counter a
olga55 [171]

Answer: Informal bench-marking

Explanation:

Informal bench-marking is defined as unconscious comparison of one's own behavior, skills, values etc with other and learning from them to improve. This leaning can be found in work-place, home, school etc.

  • According to the question, Myles is using informal bench-marking through studying other stores complaint handling style and reduction technique so that he can learn from it.
  • Other options are incorrect because designing analysis,outcome analysis, issue analysis and processing of complaining ta re not the comparison that unconsciously done by person .
  • Thus, the correct option is informal bench- marking.
4 0
3 years ago
What do economists call a decline in the real GDP combined with a temporary rise in price level?
ad-work [718]
A <span>stagflation is my answer.</span>
3 0
3 years ago
Read 2 more answers
When a typist changes from a conventional typewriter to a word processor, his typing schema will have to _____ to incorporate th
Elis [28]
<span>The schema will have to accommodate to make the person more easily able to perform the new task. Accommodation allows the new information to be made a part of a schema without changing the overall concepts in the schema. The schema itself stays unchanged for the most part, but the new information is more of a "tweak" to the schema than a full-on update.</span>
8 0
3 years ago
On a router configured to use RIP, the number of routers a packet must travel between before it reaches its destination is calle
11111nata11111 [884]

Answer:

metric

hop count

Explanation:

6 0
3 years ago
Choose a firewall that is currently on the market and write a technical "sales pitch" to your classmates on why they should choo
stellarik [79]

Answer:

I would propose Comodo Firewall to my schoolmate. It is very easy to understand and have an appealing graphical UI. It gives the most significant level of security from dangers. It checks all the traffic going to the framework and leaving the framework. It quickly cautions you when there is any sort of suspicious action. There are no mind boggling design issues. It learns the conduct of the client to convey customized protection. It gives you the usefulness of Spyware filtering and infection checking in a single tick. There are a lot more functionalities that the firewall gives to its clients.

Explanation:

Choose a firewall that is currently on the market and write a technical "sales pitch" to your classmates on why they should choose the firewall you are selling.

I would propose Comodo Firewall to my schoolmate. It is very easy to understand and have an appealing graphical UI. It gives the most significant level of security from dangers. It checks all the traffic going to the framework and leaving the framework. It quickly cautions you when there is any sort of suspicious action. There are no mind boggling design issues. It learns the conduct of the client to convey customized protection. It gives you the usefulness of Spyware filtering and infection checking in a single tick. There are a lot more functionalities that the firewall gives to its clients.

3 0
3 years ago
Other questions:
  • How can you clean out the scales in an electric iron without taking the iron apart? A. By rinsing the tank and holes with a wate
    12·2 answers
  • How do I write code in Java for "A spinner for a game has four possible options: blue, red, yellow, green. The chance of landing
    10·1 answer
  • What is the difference between a design pattern and a DLL?
    12·1 answer
  • Robert works in a call center and receives a call from Kathy. Kathy says she can no longer access the online reporting applicati
    13·1 answer
  • How do you know where the home row of the keyboard is?
    14·2 answers
  • What word describes a violation of copyright laws? What rights do copyright holders have over their work of art
    5·2 answers
  • What is a task that is not associated with loading existing data into a new ERP system.
    11·2 answers
  • Write a method named removeRange that accepts an ArrayList of integers and two integer values min and max as parameters and remo
    10·1 answer
  • Which of the following online creation tools will be used if a person wants to create a video presentation?
    8·1 answer
  • . prevalence of coronary artery disease in patients with isolated aortic valve stenosis. br heart j. 1984;51:121–4.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!