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
k0ka [10]
3 years ago
12

Write the AddressList method newBusiness. This method searches addresses for an existing business with an identical address (i.e

. an address object for which street matches st and number matches no). If this is found, then the method updates the item in the list to an address with name nm, street st and number no. If no entry with a matching street and number exists, then the method adds a new address to the end of the list with name nm, street st and number no. The method should return the index on Addresses where the address has been updated or added.
Business
1 answer:
max2010maxim [7]3 years ago
5 0

Answer:

See explaination

Explanation:

// Address.java

public class Address {

/**

* The name of the business

*/

private String name;

/**

* The name of the street the business is on

*/

private String street;

/**

* The street number of the business

*/

private int number;

/**

* Constructs an Address that represents a business with name nm,

* at number no on the street st

*/

public Address(String nm, String st, int no)

{

name = nm;

street = st;

number = no;

}

/**

* Returns the name of the business

*/

public String getName()

{

return name;

}

/**

* Returns the name of the street on which the business is located

*/

public String getStreet()

{

return street;

}

/**

* Returns the street number of the business

*/

public int getNumber()

{

return number;

}

}

//end of Address.java

//AddressBook.java

import java.util.ArrayList;

import java.util.List;

public class AddressBook {

/**

* The list of business addresses. No two businesses in the list

* can have the same address (both the same street and street number)

*/

private List<Address> addresses;

/**

* Constructs an empty AddressBook

*/

public AddressBook()

{

addresses = new ArrayList<Address>();

}

/**

* atparam st the name of a street

* atreturn a list with the names of each business with an address on that street

*/

public List<String> onStreet(String st)

{

// create an empty output list of names of business

List<String> businessName = new ArrayList<String>();

// loop over the list of addresses

for(int i=0;i<addresses.size();i++)

{

// if ith street of address = nm, add the name of the business to the output list

if(addresses.get(i).getStreet().equalsIgnoreCase(st))

businessName.add(addresses.get(i).getName());

}

return businessName; // return the list

}

/**

* Searches for an existing business with an identical address (street and number

* both match). Updates the record to an address with name nm, street st and number no.

* If no entry already exists adds a new address to the end of the list with these parameters.

*

* atparam nm the name of the business

* atparam st the street the business is on

* atparam no the street number of the business

* atreturn the index of where the business address is on the list

*/

public int newBusiness(String nm, String st, int no)

{

// loop over the list of addresses

for(int i=0;i<addresses.size();i++)

{

// if ith index addresses match the street and number of the input st and no

if((addresses.get(i).getStreet().equalsIgnoreCase(st)) && (addresses.get(i).getNumber() == no))

{

addresses.remove(i); // remove the ith address from list

addresses.add(i, new Address(nm,st,no)); // add a new address with the input name, street and number at ith index

return i; // return the index i

}

}

// if no address match, add the business at the end of the list

addresses.add(new Address(nm,st,no));

return addresses.size()-1; // return the last index

}

}

//end of AddressBook.java

You might be interested in
What is the problem the manager faces? who is the decision maker? what is the decision setting or context, and how does it influ
spin [16.1K]

The trouble the manager faces: A decision can be described as a path of motion purposely chosen from a hard and fast of options to reap organizational or managerial targets or dreams.

The definition of a manager is a person answerable for supervising and motivating personnel and for steering the progress of a business enterprise. An instance a manager is a person that is in charge of customer service deals with consumer disputes and oversees and supervises customer support dealers.

Manager . a boss is absolutely the individual above you inside the company hierarchy, even as a manager is someone who has a degree of control or obligation within the organization or employer. an MD is a person that is supervising you.

A supervisor is a professional who takes a leadership position in an organization and manages a crew of personnel. frequently, managers are answerable for coping with a specific department of their enterprise. there are many varieties of managers, however, they usually have obligations like undertaking performance evaluations and making choices.

Learn more about manager here: brainly.com/question/24708179

#SPJ4

4 0
1 year ago
The ways you act, think, and feel describe your _____.
Bas_tet [7]
Personality traits... i think

have a good day
4 0
3 years ago
Without division of labor, no specialization. Discuss​
melomori [17]
Ncncncncmckckclslalamsnndnx
7 0
2 years ago
Read 2 more answers
What is a consumer product?
Zepler [3.9K]

Answer:

sorry po talaga need po points

4 0
2 years ago
Read 2 more answers
Maria spots a beautiful dress in the window of a boutique. Maria goes into
Yakvenalex [24]

Answer:

Asking Price

Explanation:

8 0
3 years ago
Other questions:
  • One of the key motives for mergers is​ ________. A. reducing the marginal tax rate B. to sell the assets of the target company t
    9·1 answer
  • How does an organization specify the aspects of performance that are relevant to the organization? select one:
    12·1 answer
  • A company manufactures and sells a product for $124 per unit. The company's fixed costs are $72,760, and its variable costs are
    6·1 answer
  • Suppose Susan owns a business that operates in a market characterized by monopolistic competition. Susan's profit-maximizing pri
    9·2 answers
  • The city of Hapeville announces that a new community college will be built in the city. Which is NOT a likely result of the new
    15·1 answer
  • The equal credit opportunity act (ecoa) makes it illegal for lenders to refuse credit to or otherwise discriminate against which
    10·1 answer
  • Which of the following is a service supplying vehicle title records and damage reports?
    14·2 answers
  • How has the steam engine changed over time?
    14·1 answer
  • Carver, Inc. uses the weighted-average method in its process costing system. The following data concern the operations of the co
    13·1 answer
  • The day they go on sale, Beth forgets her money to buy season tickets to the high school basketball games. Randall has extra cas
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!