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
malfutka [58]
3 years ago
12

Write the one Sale method of the GroceryStore class. Method oneSale has one parameter: the name of one product (that a customer

would like to buy). Method oneSale should attempt to carry out the sale of the named product, and it should return true or false depending on whether the sale is successful. The sale is successful if there is a product in the stock array with the given name and if the number of items in stock of that product is greater than zero. In that case, one Sale should subtract one from the number of items in stock and return true. If there is no product in the stock array with the given name or if the number of items in stock for that product is less than or equal to zero, oneSale should return false.
Computers and Technology
1 answer:
DIA [1.3K]3 years ago
8 0

Answer:

Check the explanation

Explanation:

bool oneSale(string item){

for(int i=0;i<capacity;i++){ // iterate till the capcity of array

if(item==grocerryList[i].name()){ // if name matches

 if(grocerryList[i].getStock()>0){ // and stock is greater than 0

  grocerryList[i].setStock(grocerryList[i].getStock()-1); // subtract 1 from the stock

// or alternate is grocerryList[i].stock= grocerryList[i].stock-1;

 return true; // return true

}

}

else if(item==grocerryList[i].name()){ // if name matches

 if(grocerryList.getStock()==0){ // but stock is empty

 return false; // return falsse

}

}

else{ // means item is not available so there is no need to check stock

return false; // return false

}

}

}

You might be interested in
Characteristics of successful entrepreneurs include
crimeas [40]
The answer would be A because grit means to fight hard to get what you want. Submission would be to give in to pressure and give up. Self-importance would be to only focus on yourself and no one else. A short attention span would not work out for you because you get distracted easily.
8 0
4 years ago
The valence electron configurations of several atoms are shown. how many bonds can each atom make without hybridization? 2s^2 2p
Pie
Answer: This element needs 3 electrons to complete its octet state

Why?:
since the electrons in 2s2 are already paired they cannot form a bond pair with electrons from other elements without hybridisation however the 3 electrons in 2p3 are unpaired so can form bond pairs with electrons from other elements without hybridisation.

Hope this helps!
3 0
4 years ago
1. What conversion factor should be used to convert from Gigaliters to liters?
Ilia_Sergeevich [38]
The conversion factor is 10 to the 9th power
5 0
3 years ago
The methods of the Character class that begin with ____ return a character that has been converted to the stated format.
Pavel [41]

Answer:

most probably the answer is 'to'

6 0
3 years ago
Difference between volatile and non volatile memory
slega [8]
<span>Volatile memory requires electricity or some kind of current to store information, and nonvolatile memory does not.</span>
6 0
3 years ago
Read 2 more answers
Other questions:
  • Consider a load-balancing algorithm that ensures that each queue has approximately the same number of threads, independent of pr
    14·1 answer
  • If you like to spend time outdoors working with plants and animals, you have a(n) _____. a. bodily/kinesthetic learning style b.
    6·2 answers
  • Osha requires employers pay for most required personal protective equipment including
    11·1 answer
  • 5. Write a 500- to 1,000-word description of one of the following items or of a piece of equipment used in your field. In a note
    13·1 answer
  • A technician has just finished installing a secondary OS on a workstation. After rebooting the computer, the technician receives
    13·1 answer
  • Which is the correct APA format in books?​
    10·2 answers
  • which of the following is something that an information systems (IS) professional would do? A. devise new ways to use computers
    10·1 answer
  • A user purchased a new smart home device with embedded software and connected the device to a home network. The user then regist
    5·1 answer
  • How did New York Governor Hugh Carey handle Sostre’s situation?
    9·2 answers
  • Rewrite the following program segment using a while loop instead of a for loop.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!