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

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 12:10, Ryantimes2
On a average work day more than work place firs are reorted
Answers: 1
image
Engineering, 04.07.2019 18:10, DestyHilBan1183
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
image
Engineering, 04.07.2019 18:10, lerasteidl
Determine whether or not it is possible to compress air adiabatically from k to 140 kpa and 400 k. what is the entropy change during this process?
Answers: 3
image
Engineering, 04.07.2019 18:10, demarcuswiseman
Calculate the bore of a cylinder that has a stroke of 18 inches and an extension time of 6 seconds at a flow rate of 4 gal/min.
Answers: 3
You know the right answer?
The class defines the following private instance variables: a. recipient -a string representing the...

Questions in other subjects:

Konu
Mathematics, 14.12.2020 22:10
Konu
Mathematics, 14.12.2020 22:10