Lessons-Object Oriented Class Notes Revise Them
Lessons-Object Oriented Class Notes Revise Them
• Java classes contain fields and methods. A field is like a C++ data member, and a
method is like a C++ member function. In Java, each class will be in its own .java
file.
Question:
During an objected oriented class in St Paul’s University, students were asked to
implement different access level in fields and methods in there object oriented
practical quiz. Explain the access levels that the students were required to
implement.
Question:
the difference between an object in an object oriented language and a variable
• A variable is simply a name given to an area of memory which the program will
use. In a typed language the compiler is able to constrain what type of data is
placed into this memory location.
• An object also identifies an area of storage for data, additionally however, it also
determines what operations may be applied to that data
the responsibility principle
i. Activity diagrams.
ii. Sequence diagrams.
iii. Class diagrams.
iv. State diagrams.
Construct a UML class diagram showing the
structure of a professional society, wherein
members pay an annual fee. Your class diagram
should incorporate the following 6 classes: member,
studentMember, standardMember, seniorMember,
society, and governingCommittee, which should be
connected with appropriate relationships, and be
populated with appropriate instance variables and
methods to enable the names, addresses and fees
of members to be stored, along with the
management committee members, and the name
and HQ address of the society. The governing
committee will comprise a number of senior member
The Library of Macmillan is a public library that stores various items that can be borrowed,
including books, journals, music, photographs and films. The Library is open to both
members and non-members, but only members can borrow items. There is a limit of ten
items in total that can be borrowed. Members must join first, by providing proof that they
live in the Birmingham area. The library also provides facilities such as Wi-Fi and
photocopiers, which both members and non-members can apply to use. Books can be
borrowed for two weeks and other items, such as music and films for one week. If the
borrower keeps the item longer than this, they are subjected to a fine, which is increased
daily. When a member borrows an item, they provide their libraryNo, if this is valid their
loan details are checked to ensure that the items to be borrowed will not take them over
the maximum number of permitted items. A check is also made to see if they have any
fines. If they have a fine, then they cannot borrow any items until the fine is paid. If all the
checks are ok, then the item is issued to the member and the return date is assigned to the
loan. At this point the member can optionally ask for a printout, which summarises all of
the items they have on loan and when each item is due back. Library members can reserve
items that are currently out on loan. If an item proves to be very popular, then the librarian
will order a new copy, provided the cost does not exceed the budget. Members can
register for online facilities so that they can check their own loan details at any time. Once
registered a member can also renew their loans online, provided that the item has not
been reserved.
•Write down a use case description of the way a member borrows a book. Your answer should
include a normal sequence and three alternative sequences
•Draw a use case diagram for the library system
Write down a use case description of the way a member borrows a book. Your answer should
include a normal sequence and three alternative sequences
• i) Behaviour diagrams
• ii) Structure diagrams
• iii) Interaction diagrams
Behavior Diagrams
• Answer:
• class Student {
• attribute string name;
• attribute Date dateOfBirth;
• attribute string address;
• attribute string phone;
• // plus relationship and operations . . .
• };
In ODL, define a class course
• Answer:
• class Course {
• attribute string crse_code;
• attribute string crse_title;
• attribute short credit_hrs;
• // plus relationships and operation . . .
In ODL, define user structures by
using the keyword struct
• struct Address {
• string street_address;
• string city;
• string state;
• string zip;
• }
• struct Phone {
• short area_code;
• long personal_number;
• }
• attribute set _ phone _ phones
In ODL,define the operations for
class; student.
• class Student {
• attribute string name;
• attribute Date dateOfBirth;
• //user-defined structured attributes
• attribute Address address;
• attribute Phone phone;
• //plus relationship
• //operations
• short age( );