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, 03.07.2019 14:10
The y form of iron is known as: a) ferrite b) cementite c) perlite d) austenite
Answers: 3
question
Engineering, 04.07.2019 18:10
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
question
Engineering, 04.07.2019 18:10
Water in a partially filled large tank is to be supplied to the roof top, which is 8 m above the water level in the tank, through a 2.2-cm-internal-diameter pipe by maintaining a constant air pressure of 300 kpa (gage) in the tank. if the head loss in the piping is 2 m of water, determine the discharge rate of the supply of water to the roof top in liters per second.
Answers: 3
question
Engineering, 04.07.2019 18:10
You are making beer. the first step is filling the glass carboy with the liquid wort. the internal diameter of the carboy is 15 in., and you wish to fill it up to a depth of 2 ft. if your wort is drawn from the kettle using a siphon process that flows at 3 gpm, how long will it take to fill?
Answers: 1
You know the right answer?
The class defines the following private instance variables: a. recipient -a string representing the...
Questions
question
History, 06.05.2020 03:15
question
Mathematics, 06.05.2020 03:15
question
Mathematics, 06.05.2020 03:15
question
Mathematics, 06.05.2020 03:15
question
Health, 06.05.2020 03:15
question
Mathematics, 06.05.2020 03:15
question
Chemistry, 06.05.2020 03:15
Questions on the website: 13722361