Question
Now imagine that you're writing client code for your revised ValuePair class - i.e., code in a different class that uses ValuePair objects. For each
Now imagine that you're writing client code for your revised ValuePair class - i.e., code in a different class that uses ValuePair objects.
For each of the following tasks, write a single line of client code to accomplish the task:
Construct a ValuePair object for the pair (7, 15.5), and assign it to a properly declared variable named vp1.
A. Change the integer value in the ValuePair object that you created in part (a), giving it a value of 25. You should not create a new object; you should change the internals of the existing object.
Important: As a result of your changes from part 1, clients no longer have direct access to the fields B. in a ValuePair object. As a result, you will need to make a method call to change the appropriate field.
C. Get the real-number value in the ValuePair object that you created in part (a), and assign it to a properly declared variable named b1. Here again, you will need to make an appropriate method call.
D. Now imagine that you are given a second ValuePair object that has been created by someone else and that has been assigned to the variable vp2. Change the integer value in vp2, giving it a value that is 2 more than its current value.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Here are the client code lines to accomplish each task A Construct a ValuePair ob...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started