Classes describe objects. Objects have two types of components: Responsibilities and State. The responsibilities describe actions or responses that every object based on that class can perform. In other words, all objects in a class have the same responsibilities. The State is the set of values that comprise an object (instance) of the class. In contrast to responsibilities, each object's state is usually different from that of the other objects of the same class.
For instance, consider a class which describes a bank account. There will be a lot of accounts, but the responsibilities of all accounts will be the same: to allow adding money, taking money away, and so on. However, the state (amount of money) of every account object is different.
Instance variables hold the state. An object of the class has a "has-a" relationship with its instance variables.
Methods carry out the responsibilities.
In this assignment you will create a class which describes books. There are certain things a book can do: display information about itself such as its title and its price, and so on.
You will define features of books in a Book class. You will then use that class to create 2 specific book objects. Finally, you will send messages to those books asking them to do things they are supposed to know how to do.
The accessor methods in the Book class should be named as follows:
getPublisher
getTitle getAuthor getYear getISBN |
This method returns the publisher information. This method returns the title information. This method returns information about the author. This method returns the year of publication of the book. This method returns the ISBN information. |
setPublisher
setTitle setAuthor setYear setISBN |
This method sets the publisher information.
This method sets the information about the title. This method sets the information about the author. This method sets the year of publication of the book. This method sets the ISBN information. |
Your Book class must have the ten methods mentioned above. If
you wish, you can also provide a constructor which does not require any
input parameters, and can provide additional constructors which accept
parameters but these are not required. If you do not provide any constructors,
Java will provide a simple one with no parameters for you.