
|
|
Magercises:
Java Object Model
Introduction
These Magercises explore the use of classes and
interfaces as well as run-time type information and
Java's dynamic nature.
There are eleven Magercises to complete:
- A Simple Class
Create a simple class with a construtor and some
methods. Educational goal(s):
- Syntax of class and method declaration.
- Creation of class constructors.
- Implementation of basic methods.
- Some Methods
Extend the functionality of the previous
Magercise using Arrays and Strings.
Educational goal(s):
- Variable initialization.
- Managing arrays in a dynamic context.
- Implementation of a toString
method for a Class.
- Working With
Packages
Create a package by splitting up a .java
file. Educational goal(s):
- Use of import and package
statements.
- Organization of java packages.
- Using
Inheritance
Using previous classes created in Java
Basics, abstract a superclass. Educational
goal(s):
- Learn about super and subclasses.
- Learn how classes can inherit behavior
from a superclass.
- Using Interfaces in
Java
Interfaces make Java more flexible than many
previous object-oriented languages. This
Magercise defines a Client interface
that works either for an individual or a company
object. Educational goal(s):
- Study the use of interfaces to describe
skills.
- Learn how interfaces allow you to access
unrelated objects with the same
programming interface.
- Working With Class
Information
Modify the Company class created in the Java
Basics Magercises to contain method totalIndividualContracts,
which computes the total value of all contracts
dealing with individuals. Educational goal(s):
- Learn about the Class definition
objects.
- Explore Java run-time type information.
- Using Static
Methods to create a Singleton
Create a PersonFactory using static
members. Educational goal(s):
- Learn about class variables and methods.
- Learn to use member access specifiers.
- Stacks and Queues as
Interfaces
Create a class QStack that can behave
like a Queue and a Stack. Educational goal(s):
- Learn how one object may play many roles.
- Explore the use of interfaces in data
structure implementation.
- Catching Exceptions
Add exception handling code to an existing
program that throws some common exceptions. Educational
goal(s):
- Learn about the syntax and behavior of
exception handlers.
- Note some common exceptions.
- Creating and Throwing
Exceptions
In an airplane manufacturing process, annotate
the code to catch errors in process. Educational
goal(s):
- Learn to throw exceptions.
- And Finally...
Enhance the previous Magercise to have better
error handling; the finally clause is
introduced. Educational goal(s):
- Learn about finally clauses.
|