Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

SE 450: OO Software Development: Assignment 1: OOP Principles and UML Class Diagram

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

SE 450: OO Software Development

Assignment 1: OOP Principles and UML Class Diagram

Instructor: Vahid Alizadeh


Email: v.alizadeh@depaul.edu
Quarter: Winter 2021

Last update: January 22, 2021


Assignment 1: OOP Principles and UML Class Diagram

Submission

Due date: February 4 - 5:00 PM


How to submit:
Prepare your answers in a PDF file for all exercises. Compress the PDF document
and all Java source codes into a single file.
You must address the source code file name in your PDF document for related
exercises. Please provide your name and exercise info as a comment in the header of
each source code.
Submit on D2L (Submissions > Assignment 1).
If you have any problem:
Review the lecture OR ask for help on the course forum.

Goals

Setting up the environments required for this course correctly.


Understanding and practicing object-oriented programming concepts and principles.
Understanding and practicing UML class diagrams and generating the code from it.

K Assignments k

 Exercise 1. (10 pts) True or False Statements:


1. The implementation of inheritance always involves writing a few less lines.
2. The following class declaration is incorrect:
public final class Class extends OtherClass {...}

3. Inheritance is only useful if specialization is used. In fact, specializing we inherit in the


subclass (or subclasses) members of the superclass that we must not rewrite. Instead with
the generalization we create an extra class, and then we write more code.
4. The super keyword allows you to call superclass methods and constructors. The keyword
this allows you to call methods and constructors of the same class.
5. Multiple inheritance does not exist in Java because it does not exist in reality.
6. A subclass is “bigger” than a superclass (in the sense that it usually adds new features and
functionality compared to the superclass).
7. Suppose we develop an application to manage a soccer tournament. There is inheritance
derived from specialization between the Team and Player classes.
8. Suppose we develop an application to manage a soccer tournament. There can be inheri-
tance derived from generalization between the Team and Player classes.
9. In general, if we had two classes, Father and Son, there would be no inheritance between
these two classes.
10. An interface can extend an abstract class and an interface.
 Exercise 2. (20 pts) Create an encapsulated Book class, so that it abstracts the concept of a book
that can be sold in a bookstore. Among the fields defined by the Book class, there must be the
genre field (understood as a literary genre). Let’s make it possible for a book to be associated
with only a literary genre included between a set of predefined literary genres, for example the
set consisting of the genres: novel, thriller, essay, manual. Create a class that tests that Book
objects work correctly.
 Exercise 3. (20 pts) Taking into account the previous exercise, create also the Bookcase
class (understood as a bookcase inside a bookstore). Each bookcase must be dedicated to a
certain literary genre included in the list of genres chosen in the previous exercise, and therefore
must contain only books of the same genre. In the Bookcase class there must be a method
called addBook(Book book), which allows you to add a book with the correct genre to the
bookcase. Also create the Bookstore class. A bookstore must contain only one bookcase for
each genre, and therefore it is necessary to prevent that two bookcases with the same genre can
be added. In addition, the Bookstore class must implement the Singleton pattern. Finally create
a BookstoreTest class, which creates an object of type Bookstore adding to it objects of type
Bookcase to which have been added objects of type Book. Verify that two bookcases with the
same genre cannot be added to the bookstore.

Note You can redefine the Book class if it is necessary.
 Exercise 4. (20 pts) Resuming the solution of the previous exercise, let’s suppose we want to
make our bookstore sell also music albums. So, let’s abstract the Album class, bearing in mind
that even for music albums there is an identification number called ISMN (although there are
other ways to identify an album as using the European EAN standard), as well as for books there
is the ISBN identification number. Then check if there is an inheritance relationship between the
Book class and the Album class. If it exists, implement a solution.
 Exercise 5. (20 pts) Write a Java program to implement the class diagram exactly as you see it
below:
 Exercise 6. (10 pts) Draw a UML class diagram for the following scenario:
A furniture factory intends to implement an information system to store all data on the
different types of furniture and components it produces:
The factory produces several lines of furniture, each with a different name and consisting
of several pieces of furniture of different types (beds, tables, chairs, . . . ).
All furniture pieces have a type, a single reference (eg CC6578) and a selling price.
The major competitive advantage of this innovative plant is the fact that each component

2
Figure 1: Exercise 5 UML class diagram

produced can be used in more than one piece of furniture


Each piece of furniture is thus composed of several components. The same component
can be used more than once in the same piece.
Every type of component produced is assigned a unique numerical code, a manufacturing
price and a type (screw, hinge, shelf . . . ).
The furniture is then sold in various stores throughout the world. Each store has a different
address and a fax number.
To make the manufacturing process more efficient, stores have to place orders every time
they need to replenish their stock. These orders must also be stored in the database.
Each order has an order number, a date, the store that placed the order as well as a list of
all the ordered furniture and their quantities.

- Don’t forget to ask for help in the course forum in case you have any problem.
- Enjoy OO programming!

You might also like