Write a class for a fruit basket

Assignment Help Computer Engineering
Reference no: EM132193781

Question :

(a) Write a C++ class for a fruit basket.

The following are the properties:

Class Name :

Fruit Basket

Fields :

apples = an integer equal to the number of apples in the basket

oranges = an integer equal to the number of oranges in the basket

peaches = an integer equal to the number of peaches in the basket

Methods :

getApples rightarrow returns an integer equal to the number of apples

getOranges rightarrow returns a integer equal to the number of oranges

getPeaches rightarrow returns an integer equal to the number of oranges

getTotal rightarrow returns the total number of apples and oranges

(b) Write a main C++ function that will:

1. Instantiate and object called myBasket of the class FruitBasket

2. Assign a value of 5 to the apples field of myBasket

3. Assign a value of 7 to the oranges field of myBasket

4. Assign a value of 10 to the peaches field of myBasket

5. Use the method getTotal to display the total number of fruit items in the basket

6. Use the "using" statement to define the namespace.

Reference no: EM132193781

Questions Cloud

Determine the velocity of the plane relative to ground : An earoplane flying at velocity of 900 km/h at an angle of 30 degrees to the east enters a region where the wind is blowing at 100km/h n the north easterly.
Prepare a program to implement the client-server directory : Write a C/C++ Program. Client/Server Directory. The application you will write for this implements a directory server.
Use a random number generator to create a 1 row : Write a C/C+ program that uses a random number generator to create a 1 row, N column vector of random numbers RN[] between min and max.
What is the role of government in a democracy : Please define and explain what it means to live in a democracy. What is a democracy? What is the role of government in a democracy?
Write a class for a fruit basket : Instantiate and object called myBasket of the class FruitBasket . Assign a value of 5 to the apples field of myBasket.
Why rule of law seen as cornerstone of development policy : Why is the rule of law seen as a cornerstone of development policy? Is transnational law the solution to a problem or a problem in itself? Explain
In what ways is the electoral college representative : In what ways is the Electoral College representative and fits in with the ideals of democracy? In two to three paragraphs, make an argument in support.
Write a class that use the main function : The program prompts the user for four different food types and the best way to cook it. An example might be "cat" and the best way to prepare it might be.
Create a random number vector containing n numbers : Create a random number vector containing N numbers, between the lower and upper limits of MIN and MAX, respectively.

Reviews

Write a Review

Computer Engineering Questions & Answers

  What will happen to network density

By what percent has the number of nodes increased? Suppose the new node has a typical (median) number of connections. What will happen to network density?

  Write down problem on strings in java

Write down problem on strings in java

  Find the critical and noncritical races

For the following flow table: find all the races.

  Develop an outline of project plan for the testing

As part of the Disaster recovery planning at a medium sized business you have been asked to develop a project plan test the backups of production systems.

  Where is the reason of most of the attacks

Where is the reason of most of the attacks.explain the differences between the two main classes of intrusions: misuse and anomaly.

  Explain the need for designing procedures

Explain the need for designing procedures for simple tasks such as creating or modifying access controls. Create a procedure guide that provides clear.

  Kinds of digital and logical evidence

State some of the kinds of the digital and logical evidence, and special content data investigators may require to gather during an actual cyber-terrorism case.

  Determine the importance of forensic tool testing

Determine the importance of forensic tool testing and validation and if this is a critical component of your forensic operations. Justify your answer.

  What are the two rules that a reference monitor enforces

What are the two rules that a reference monitor enforces? What properties are required of a reference monitor?

  How many probes are involved when double hashing is used

About how many probes are involved when double hashing is used to build a table consisting of N equal keys?

  Constructing truth table of converter circuit

Construct the truth table of the converter circuit using character a , b, c and d (d represents Least Significant Bit) in order to denote the literals input of BCD. Use w, x, y and z (z as Least Significant Bit) in order to represent the output li..

  How to develop a class named stock tracker

How to develop a class named stock tracker that takes the definitions: The constructor "StockTracker ()" creates an initially empty StockTracker object buy(quanity, price) method performs a purchase transaction.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd