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]
4 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]4 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
Bank panics:
barxatty [35]
The answer to this question is letter B.

Bank panics are a risk of fractional reserve banking but are unlikely when banks are highly regulated and lend prudently. Bank panic is a situation where a financial crisia occurs when depositors will try to convert their deposits into cash or withdraw their deposit in the bank. In order for the banks to prevent this kind of crisis, banks will have to keep a higher reserves and commercial banks should be kept regulated always.
7 0
3 years ago
True or false: it is recommended to minimize interruptions in cpr for pulse checks and shocks.
wolverine [178]

The statement "it is recommended to minimize interruptions in CPR for pulse checks and shocks." is TRUE. Option A

This is further explained below.

<h3>What is CPR?</h3>

Generally, In an effort to manually maintain intact brain function while additional steps are taken to reestablish spontaneous blood circulation and respiration in a person who is experiencing cardiac arrest, cardiopulmonary resuscitation, or CPR, is an emergency procedure that involves chest compressions that are frequently combined with artificial ventilation.

In conclusion,  It is suggested to minimize pauses in chest compressions for pulse checks and shocks. The remark that "this should be done only when needed" is accurate.

Read more about CPR

brainly.com/question/28450734

#SPJ1

3 0
2 years ago
You are a lawyer representing a client who lost their $1 million home in a house fire. They are suing the home’s architect as de
belka [17]

Answer:

They would have to compensate about 2million$

Explanation:

The person should be 100% reimbursed, and also a person should be compensated for the time this inconvenient coincidence had taken out of this individuals time away from work and time away from safety and convivence of their 1,000,000 home.

3 0
4 years ago
What type of pricing tactic is being used when several airlines
Blababa [14]

Horizontal Price Fixing.


That's if they were to charge the same fare for a single route......

3 0
3 years ago
Explain Jodi's self esteem throughout Tall Girl? Movie
stiks02 [169]

Answer:

Poor

Explanation:

Jodi is very self-concious about her height. She thinks that it makes her different than other "normal" people among her peers, or even inferior to more feminine, smaller girls.

6 0
3 years ago
Read 2 more answers
Other questions:
  • What is a poor label for a category level file folder?
    8·1 answer
  • Continuous pressure from looming deadlines is a stressor because it causes people to _______.
    15·2 answers
  • Stone Company produces carrying cases for CDs. It has compiled the following information for the month of June: Physical Units P
    9·1 answer
  • A rectangular box has a volume of $4320$ cubic inches and a surface area of $1704$ square inches. The sum of the lengths of its
    15·1 answer
  • Sheffield Corp. earned $2120 for architecture services provided with the fee to be paid in the future. No entry was made at the
    9·1 answer
  • The Shoe Store has cash of $300, accounts receivable of $700, accounts payable of $800, inventory of $1,300, long-term debt of $
    15·1 answer
  • Which of the following is NOT an example of a metric<br> ?
    14·1 answer
  • California Company included the following items in its financial statements for ​, the current year​ (amounts in​ millions):
    6·1 answer
  • Real and nominal income is calculated respectively at----
    14·1 answer
  • Calculate the transaction value (in $ thousands) of a theoretical company based on the information provided below. Current Share
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!