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
If I bought mine craft p.e. for 7.99 and hook my Micro soft account up, will i get java edition
katrin [286]
No, they are two diff things
5 0
2 years ago
Can you show me how to code this is GDBonline? explaining each statement with notes//
MAVERICK [17]

Answer:

Create two classes, PlayingCard and Main, as depicted in the attachments.

Explanation:

The getters/setters are not actually used in this code, but creating them is pretty standard. Although, you could argue that a PlayingCard object should never change value/suit, and is what it is as long as it exists. Such objects would be called "immutable".

7 0
2 years ago
Write a function writel that will write the length of a side of a square. If only one argument is passed to the function, it is
Levart [38]

def writel(length, file_name = ""):

   if file_name!="":

       f = open(file_name, "w")

       f.write(str(length))

       f.close()

   else:

       print(str(length))

writel(3, "FileName.txt")

I hope this helps!

Remember, you must have the file created prior to running this program. Best of luck.

7 0
3 years ago
If we are using an 4-character password that contains only lowercase English alphabetic characters (26 different characters), ho
Trava [24]

Answer:

11,424,400 possible passwords

Explanation:

Since all characters are letters and only lowercase

we have 26∧4 = 456,976 possibilities

For a 5-character password which is still lower case sensitive.

we have 26∧5 = 11,881,376 possibilities

Many more possible passwords = (11881376-456976)

= 11,424,400 possible passwords

6 0
3 years ago
Read 2 more answers
Green computing can be achieved by: a. using video conferencing, electronic meeting systems, and groupware. b. replacing meeting
Rama09 [41]

Answer: using video conferencing, electronic meeting systems, and groupware

Explanation:

Green computing simply means the use of computer in a way that's environmental friendly.

One way to achieve this is through using video conferencing, electronic meeting systems, and groupware. This allows the use of computers not to have a negative effect on the environment.

4 0
3 years ago
Other questions:
  • When computers are connected and operate through one main computer, it is called a _________ network
    14·2 answers
  • Which technology uses regular phone lines and transmits at speeds up to 256 kbps?
    15·2 answers
  • The rules that determine what is allowed in a program are known as the
    14·1 answer
  • PLEASE HURRY!!!!!!!!!! WILL MARK BRAINLIEST!!
    13·1 answer
  • Where can you access email accounts on your Windows 7 computer in order to modify current account or create new ones
    15·1 answer
  • Which programming element is used by a game program to track and display score information?
    10·2 answers
  • Which statement about technology before the invention of the printing press is true?
    8·1 answer
  • On React
    13·2 answers
  • Computer hardware refers to: Group of answer choices the mechanism through which users interact with a computer. handheld comput
    13·1 answer
  • WHAT DO YOU KNOW?<br> Why would you want to change your Table<br> Properties?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!