subject
Engineering, 22.04.2020 01:46 Dmgirl123

The class defines the following private instance variables: a. recipient -a string representing the person receiving the package. b. numberOfItems - an integer representing the number of items in the package. c. description - a string describing the package’s contents.2. You can define additional instance variables.3. You can define constants (static final), but do not define static variables that can be modified.4. Constructor #1 - Takes a recipient, a number of items, and a description as parameters. It initializes the corresponding instance variables. If recipient is null, an IllegalArgumentException will be thrown (any message is fine) and further initialization will not take place.5. Constructor #2 - Takes a recipient and a description as parameters. It assumes the number of items is one. If recipient is null, an IllegalArgumentException will be thrown (any message is fine) and further initialization will not take place.6. Copy Constructor - Define a copy constructor for the class.7. addItem - Takes a string as a parameter representing the description of an item. The method will append the parameter string to the description instance variable. The number of items will be adjusted accordingly. If the parameter is null, no item will be added. The method returns a reference to the current object.8. getRecipient - Get method for recipient.9. getNumberOfItems - Get method for number of items.10. getDescription - Get method for description.11. getPackageCost – Returns an integer value representing the package cost. The cost of the package is based on the number of items. Each item costs $2. For example, if a package has 3 items, the cost will be $6.12. equals - Define an equals method for the class. Two packages are considered the same if they have the same recipient and the same number of items. The package’s description is ignored.13. merge – This method has a MailPackage as a parameter, and it will merge two packages if they have the same recipient. To merge two packages, the number of items in the current object will be increased by the number of items in the parameter object. In addition, the description associated with the parameter object will be appended to the description of the current object. If the method tries to merge to itself, no processing will take place. If the method tries to merge to a package that has a different recipient, an IllegalArgumentException (with any message) will be thrown. The method returns a reference to the current object.14. compareTo – This method will allow us to compare two MailPackage objects. It has a MailPackage as parameter and returns an integer. You can use the String class compareTo method during the implementation of this method. The MailPackage compareTo method will return:a. A negative value if the number of items of the current object is less than the parameterb. A positive value if the number of items of the current object is greater than the parameter. c. If the current object and the parameter have the same number of items, the method will return:i. A negative value if the recipient of the current object precedes the recipient of the parameter in alphabetical order. ii. A positive value if the recipient of the current object follows the recipient of the parameter in alphabetical order. iii. 0 otherwise.

ansver
Answers: 2

Another question on Engineering

question
Engineering, 04.07.2019 03:10
What precautions should you take to prevent injuries when dealing with heavy loads?
Answers: 1
question
Engineering, 04.07.2019 18:10
Adouble-strand no. 60 roller chain is used to transmit power between a 13-tooth driving sprocket rotating at 300 rev/min and a 52-tooth driven sprocket. a) what is the allowable horsepower of this drive? b) estimate the center-to-center distance if the chain length is 82 pitches. c) estimate the torque and bending force on the driving shaft by the chain if the actual horsepower transmitted is 30 percent less than the corrected (allowable) power.
Answers: 3
question
Engineering, 04.07.2019 18:10
Consider a large isothermal enclosure that is maintained at a uniform temperature of 2000 k. calculate the emissive power of the radiation that emerges from a small aperture on the enclosure surface. what is the wavelength ? , below which 10% of the emission is concentrated? what is the wavelength ? 2 above which 10% of the emission is concentrated? determine the wavelength at which maximum spectral emissive power occurs. what is the irradiation incident on a small object placed inside the enclosure?
Answers: 2
question
Engineering, 04.07.2019 18:10
Water at 55c flows across a flat plate whose surface temperature is held constant at 95c. if the temperature gradient at the plate's surface for a given value of x is 18 c/mm, find a) local heat transfer coefficient. b) heat flux
Answers: 3
You know the right answer?
The class defines the following private instance variables: a. recipient -a string representing the...
Questions
question
Mathematics, 12.05.2021 21:50
question
Mathematics, 12.05.2021 21:50
question
Mathematics, 12.05.2021 21:50
question
Mathematics, 12.05.2021 21:50
Questions on the website: 13722361