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
olya-2409 [2.1K]
4 years ago
10

Your Community Supported Agriculture (CSA) farm delivers a box of fresh fruits and vegetables to your house once a week. For thi

s Programming Project, define the class Box Of Produce that contains exactly three bundles of fruits or vegetables. You can represent the fruits or vegetables as an array of type string. Add accessor and mutator functions to get or set the fruits or vegetables stored in the array. Also write an output function that displays the complete contents of the box on the console.
Next, write a main function that creates a Box Of Produce with three items randomly selected from this list:
Broccoli Tomato Kiwi Kale Tomatillo.
This list should be stored in a text file that is read in by your program. For now you can assume that the list contains exactly five types of fruits or vegetables. Do not worry if your program randomly selects duplicate produce for the three items.
Next, the main function should display the contents of the box and allow the user to substitute any one of the five possible fruits or vegetables for any of the fruits or vegetables selected for the box.
After the user is done with substitutions output the final contents of the box to be delivered.
Computers and Technology
1 answer:
sukhopar [10]4 years ago
6 0

Answer:

C++.

Explanation:

class BoxOfProduce {

private:

   string fruit_bundles[3][5];

////////////////////////////////////////////////////////////////////////

public:

   // Methods  1, 2 and 3

   void setFruit(string fruit, int bundle, location) {

       self.fruit_bundles[bundle][location] = fruit;

   }

   string getFruit(int bundle, int location) {

       return self.fruit_bundles[bundle][location];

   }

   void printBundle(int bundle) {

       cout<<"Bundle "<<i<<endl;

       for (int j = 0; j < 5; j++) {

           cout<<fruit_bundles[bundle][j]<<", ";

       }

       cout<<endl;  

   }

};

////////////////////////////////////////////////////////////////////////

// Main

int main() {

   BoxofProduce box_of_produce1;  

   

   // Get fruit names from file and add to box_of_produce1

   ifstream myfile("fruitList.text");

   int line_number = rand() % 5 + 1;

   string fruit;

   if (myfile.is_open()) {

       for (int i = 1; i <= line_number; i++)  {

           getline(myfile, fruit);

        }

   }

   box_of_produce1.setFruit(fruit, 1);

   // Print contents of bundle 1

   box_of_produce.printBundle1(1);

   

   // Left one - Allow the user to substitute any one of the five possible fruits or vegetables for any of the fruits or vegetables selected for the box.

   return 0;

}

You might be interested in
Create a class called Minimum that provides a single class method min. min should take an array of any object that implements Co
kaheart [24]

Answer:

The required code is given below:

Explanation:

public class Minimum {

   public static Comparable min(Comparable[] values) {

       if (values == null || values.length == 0) {

           return null;

       } else {

           Comparable minValue = values[0];

           for (int i = 0; i < values.length; i++) {

               if (values[i].compareTo(minValue) < 0) {

                   minValue = values[i];

               }

           }

           return minValue;

       }

   }

}

7 0
4 years ago
What are slicers used for?
Pachacha [2.7K]

Answer:

Quickly filtering data

Explanation:

Just did the Excel instruction for Edge 2021

Plz click the Thanks button

<Jayla>

4 0
3 years ago
Which statements are true about mysql workbench? (choose three)
nika2105 [10]

Answer:

Many things are true about it

3 0
3 years ago
Modify the countUp( ) you wrote in the previous question to countUp( num), where num is a parameter. The function displays from
algol [13]

Answer:

void countUp(int num)

{

   if(num==0) //base case.

   return;

   countUp(num-1);//Recursive call.

   cout<<num<<" "; //printing the number.

}

for input num=25

Output:-1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25

Explanation:

I have used recursion to print the numbers the function is in c++ language.In every recursive call we are decreasing num by 1.As the base case is reached.Then it will backtrack from 1 to num and then we are printing while backtracking.

4 0
4 years ago
What direction would a sprite go if you constantly increased its x property? Your answer What direction would a sprite go if you
Korvikt [17]

Answer:

decrease x property,It would go left

decrease y property, it would go down

yes

Explanation:

8 0
3 years ago
Other questions:
  • 17. Which of the following is not a visible section in a File Explorer window?
    8·1 answer
  • A user receives a phone call from a person claiming to be from technical support. This person knows the users name and that the
    12·1 answer
  • Explain The Two Way Communication in full.
    10·1 answer
  • A tree can grow on rock as long as its roots can reach soil through cracks in the rock.
    6·1 answer
  • Assume a 16-word direct mapped cache with b=1 word is given. Also assume that a program running on a computer with this cache me
    6·1 answer
  • What is stored in alpha after the following code executes?
    9·1 answer
  • When workers demonstrate patience, are able to manage there emotions, and get along with other employees, which skills are being
    11·2 answers
  • What is it called when an attacker convinces you to enter personal information at an imposter website after receiving an email f
    10·2 answers
  • If anyone can help me and get this correct I will literally venmo you and give brainliest
    5·1 answer
  • Im trying to do an animation only using simplegui in python and my objective is make the ball enters frame, be confused and jump
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!