Get the entire Starting Out With Java From Control Structures Through Objects 6th Edition Gaddis Solutions Manual in PDF format instantly.
Get the entire Starting Out With Java From Control Structures Through Objects 6th Edition Gaddis Solutions Manual in PDF format instantly.
https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-objects-6th-edition-gaddis-test-bank/
https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-objects-7th-edition-gaddis-solutions-manual/
https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-objects-7th-edition-gaddis-test-bank/
https://testbankdeal.com/product/fundamentals-of-financial-management-
concise-7th-edition-brigham-test-bank/
Medical Surgical Nursing An Integrated Approach 3rd
Edition White Test Bank
https://testbankdeal.com/product/medical-surgical-nursing-an-
integrated-approach-3rd-edition-white-test-bank/
https://testbankdeal.com/product/statistics-the-art-and-science-of-
learning-from-data-3rd-edition-agresti-test-bank/
https://testbankdeal.com/product/health-assessment-and-physical-
examination-australian-and-new-zealand-edition-2nd-edition-estes-
solutions-manual/
https://testbankdeal.com/product/technology-now-your-companion-to-sam-
computer-concepts-1st-edition-corinne-hoisington-test-bank/
https://testbankdeal.com/product/macroeconomics-3rd-edition-jones-
test-bank/
Mastering Organizational Behavior 14th Edition Cooper Test
Bank
https://testbankdeal.com/product/mastering-organizational-
behavior-14th-edition-cooper-test-bank/
Chapter 8 Lab
More Classes and Objects
Lab Objectives
Be able to write a copy constructor
Be able to write equals and toString methods
Be able to use objects made up of other objects (aggregation)
Be able to write methods that pass and return objects
Introduction
We discussed objects in Chapter 6, and we modeled a television in the Chapter 6 lab. We
want build on that lab, and work more with objects. This time, the object that we are
choosing is more complicated. It is made up of other objects. This is called aggregation.
A credit card is an object that is very common, but not as simple as a television.
Attributes of the credit card include information about the owner, as well as a balance and
credit limit. These things would be our instance fields. A credit card allows you to make
payments and charges. These would be methods. As we have seen before, there would
also be other methods associated with this object in order to construct the object and
access its fields.
Examine the UML diagram that follows. Notice that the instance fields in the
CreditCard class are other types of objects: a Person object and a Money object.
We can say that the CreditCard object “has a” Person object, which means
aggregation, and the Person object “has a” Address object as one of its instance
fields. This aggregation structure can create a very complicated object. We will try to
keep this lab reasonably simple.
To start with, we will be editing a partially written class, Money. The constructor that
you will be writing is a copy constructor. This means it should create a new object, but
with the same values in the instance variables as the object that is being copied.
Next, we will write the equals and toString methods. These are very common
methods that are needed when you write a class to model an object. You will also see a
compareTo method that is also a common method for objects.
After we have finished the Money class, we will write a CreditCard class. This class
contains Money objects, so you will use the methods that you have written to complete
the Money class. The CreditCard class will explore passing objects and the possible
security problems associated with it. We will use the copy constructor we wrote for the
Money class to create new objects with the same information to return to the user
through the accessor methods.
/**
Constructor
@param road Describes the street number and name.
@param town Describes the city.
@param st Describes the state.
@param zipCode Describes the zip code.
*/
/**
Constructor
@param last The person's last name.
@param first The person's first name.
@param residence The person's address.
*/
/**
Constructor
@param amount The amount in decimal format.
*/
/**
The add method
@param otherAmount The amount of money to add.
@return The sum of the calling Money object
and the parameter Money object.
*/
sum.dollars = this.dollars +
otherAmount.dollars +
carryDollars;
return sum;
}
/**
The subtract method
@param amount The amount of money to subtract.
@return The difference between the calling Money
object and the parameter Money object.
*/
return difference;
}
/**
The compareTo method
@param amount The amount of money to compare against.
@return -1 if the dollars and the cents of the
calling object are less than the dollars and
the cents of the parameter object.
0 if the dollars and the cents of the calling
object are equal to the dollars and cents of
the parameter object.
1 if the dollars and the cents of the calling
object are more than the dollars and the
cents of the parameter object.
*/
return value;
}
V. Az idealismus.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
testbankdeal.com