Académique Documents
Professionnel Documents
Culture Documents
Q a1:
Explain the concept of class and object in object-oriented design. In your answer, do also
differentiate class and instance variables and give examples where you might use either of them
Q a2:
Explain the meaning of encapsulation in object-oriented design and desired two benefits that come
with it. How do you implement encapsulation in java?
c The term a
is used to describe the hiding of the implementation details. The process, or
mechanism, by which you combine code and the data it manipulates into a single
unit, is commonly referred to as a
. Encapsulation provides a layer of security around
manipulated data, protecting it from external interference and misuse. In Java, this is supported by
a and
a
.The advantages of encapsulation are information hiding and implementation
independence
Q a3:
Explain how polymorphism can promote extensibility. Give an example to support your explanation
c uy using polymorphism, we can add as many type to the system with or without any
modification to the general portions of the program, as long as the new class are part of the
inheritance hierarchy that the program generically. For example, if we extend class Animal
to create class Rabbit, we need to write only Rabbit class and the part of the stimulation that
instantiates a Rabbit object.
Q b1:
The EyesHaveIt.com uook Exchange is a type of euusiness exchange that does business entirely on
the Internet. The company acts as a clearing exchange for both buyers and sellers of used books.
In order for a person to offer books for sale, she/he must register with EyesHaveIt. The person must
provide a current physical address and telephone number as well as current email address. The
system will then maintain an account for this person. Acces to the system as a seller is through a
secure, authenticated portal.
A seller can list books on the system through a special Internet form. Information required includes
all of the pertinent information about the book, its category, its general condition, and the asking
price. A seller may list as many books as desired. The system maintains an index of all books in the
system so that buyers can use the search engine to search for books. The serach engine allows
searches by title, author, category and keyword.
People desiring to buy books come to sight and search for books they want, when they decide to
buy, they must open an account with a credit card to pay for the books. The system maintains all of
this information on secure servers.e
When a request to purchase is made, along with the payment, TheEyeshaveIt.com sends an email
notice to the seller of the book that was chosen. It also marks the book as sold. The system
maintains this as an open order, until it receives notice that the books have been shipped. Once the
seller receives notice that a listed book has been sold, then she must notify the buyer, via email
within 48 hours that the purchase is noted. Shipment of the order must be made within 24 hours
after the seller sends the notification email. The seller sends a notification to both the buyer and
TheEyeHaveIt.com when the shipment is made.
After receiving notice of shipment, TheEyesHaveIt.com maintains the order in a shipped statuse. At
the end of each month, a check is mailed to each seller for all of those book orders that are have
been in a shipped statuse for thirty days. The thirty-day wait is to allow the buyer to notify
TheEyesHaveIt.com if for some reason the shipment does not arrive, or if the book is not in the same
condition as advertised.
The buyers can, if they desire, enter a service code for the seller. The service code is an indication of
how well the sller is servicing book purchase. Some sellers are very active and use
TheEyesHaveIt.com as a major outlet for selling books. So a service code is an important indicator to
potential buyers.
Q b2
For the given case study, code the solution in java using classes and objects.
Creat a class called uookcollection. This class must have member inner classes called Author and
uook. The uook class must have an inner class called Chapter that represents a single piece of
chapter within a uook object. A uookCollection object must have an array of author objects and an
array of book objects. uook objects must have a single Author object, for simplicity, and an array of
Chapter objects. Add a main method to uookCollection that tests the creation of all of these objects.
Q b3
Type = loanType;
Return type;
Return cost;
Important javax.swing.*;
Public HomeLoad()
{
Super(͞Home͟);
setCost();
String input = JOptionPane. ShowInputDialog (null, ͞How many square feet is the house?͟);
Cost = 500;
Else
Cost = 350;
Import javax.swing.*;
Public CarLoan()
Super(͞Car͟);
setCost();
If(age>3)
Cost = 180;
Else
Cost = 295;
Return output;
c
c c
cc
c c
c cc
c
c
c
c
ccc
c
c !cc
c
c
!c
c
c c
c
c
"#c
c c
c c c
c $c
c
c
"cc !cc !c
#c
c c
c c c%cc
c c c%cc
c c
c%c
c
c c c
c $c
c c
c
cc
!"#c
c c
c c
&&"'( c)cc'c*c#c
c c
&&"'( cc'c*c#c
c+
!c,
c
c
c
c c !cc
c c
c
c+
!"#c
c c
c c c
c $c
c
c+
!" !cccc !cc !c
# c
c c
c c
"cc
#c
c c c%cc
c $c
c
cc
!"#c
c c
c c
&
!"#c
c c
&&"'-c'*c#c
c $c
$c
c
c
c c !c
!c
c c !c
c
c c !c!!c
c c
c
c" !c
c !cc !cccc !cc !c
# c
c c
c c
"cc
#c
c c
!c%c
c
c c
c%cc
c c !!c%cc c
c $c
c
cc
!"#c
c c
c c
c
c
c
c
c
cc" !c/0!
#c
c c
c c
cc
c c c
c c c%cc+
!"'
'c1223c' 'c' '#c
c c &
!"#c
c c c
c c c%cc"'4
c5'c'c('c'6!
'c7338c
'9:c)
'c'4
c5'#c
c c &
!"#c
c $c
$c
&c 9c;c<=
c<c
ccc c
c& c
&c ;c>-)c(?6@66cc c=
c<c
c
cc c
cc c
!c
!c!cc,c c
c
>
c c
cc
c
cc
c c
ccc
c
c6,cc
c(<c"7#c
cc c
c
cc
c
cc
cc c
,c
c
Ac
c cc c
cc
cc
c
cc
"c
,cc
c
#&c
º
a cc i c
a ccc
c c
ccc i c c c
c cc
cccc c
cc cc c
cc c c
c
c c
cc c c c c c cc c c c
c
a cc c
cc i c c c c
c
cc
c cc cc c ci c ccc
c
ccc
c cc c
r
c
i c
c cc cc cc
cccc
ccc
c
cc
c c
c
cc
c cccc
c
c
c
c