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 18:10
Courses that are developed by subject matter experts, internal or extemal to the college or university. these programs are marketed by the school (clo2) marks a)-vocational schools b)-vendor training c)-colleges & universities d)-continuing education programs
Answers: 2
question
Engineering, 04.07.2019 18:20
The characteristic roots of a dynamic system are: 1.7920 1.8160 i, -1.7920 1.8160 i, -0.4160 what is the order of this system? what are the settling time and damping ratio of the system?
Answers: 3
question
Engineering, 04.07.2019 19:10
Afoot bridge is made as a simple deck, 4 m long, with a cross section 2 m (wide) and 20 cm thick, and made of wood. the deck is supported at the two ends. the maximum load allowable on the bridge is 10 tons, provided it is uniformly distributed on the deck. to sense this load, a strain gauge is placed at the center of the bridge and its resistance is monitored. if the sensor has a nominal resistance of 350 s2 and a gauge factor of 3.6, what is the reading of the strain gauge at maximum load? the modulus of elasticity for the wood used in the construction is 10 gpa.
Answers: 2
question
Engineering, 04.07.2019 19:10
A)-explain briefly the importance of standards in engineering design. b)- what is patent? c)-explain the relationship between these standards: b.s. and b.s.en d)- in engineering design concepts, types of loads and how they act are important factors. explain.
Answers: 3
You know the right answer?
The class defines the following private instance variables: a. recipient -a string representing the...
Questions
question
Mathematics, 22.02.2021 01:00
question
Health, 22.02.2021 01:00
question
Mathematics, 22.02.2021 01:00
Questions on the website: 13722363