The Tunes database is managed by an Oracle database with IP address localhost:2000, and consists of two tables. Here are their schemas:
tune (
TID: INTEGER {pk},
NAME: VARCHAR(30),
ARTIST: INTEGER {fk})
artist (
AID: INTEGER {pk},
LNAME: VARCHAR(30),
FNAME: VARCHAR(30))
Assume you are writing an application that will allow users to download and play tunes from their favorite artists. Following the Gateway Design Pattern, implement the following classes:
TableGateway
ArtistGateway
TuneGateway
Assume you are using the DBC API for database access, which consists of the following classes and interfaces:
Sometimes, in early development, a "mock" object is needed so that testing can proceed while the real object is under development. A mock object implements the same interface as the object that will replace it.
A gateway has the following interface:
interface Gateway {
Model getModel(String fname) throws
AppError;
void saveModelAs(Model model, String fname)
throws AppError;
void saveModel(Model m) throws
AppError;
}
Where:
class Model implements Serializable {
String fname = null; // name of file
where this model is stored
boolean usavedChanges = false; // true
if modified since last save
}
Eventually, this interface will be implemented by an object that interfaces with a database system. For now, create a mock object that uses a hashtable to store models and their names.
Your team is developing an application that will create, browse, and update student records that will be stored in some sort of database. A student record contains a last name, first name, unique id number, major, and a GPA. Using the DAO and Transfer Object patterns develop an interface that the application can use to access the database. Your DAO should allow searches that return multiple records. (Hint: a null field matches anything.)
(DAO is the same as a table gateway. A transfer object is just an object that has public fields corresponding to the fields of a record from a table. Transfer objects have no methods other than constructors.)
When a patient checks into the hospital, the hospital administrator creates a patient record in the Patient Tracking System (PTS). The record initially holds the patient's name, the name of his insurance company, his policy identification number, and the name of his doctor. After the patient has been admitted, his doctor places orders for tests on the patient's record. These tests are performed by technicians, who record the results in the patient record. Next the doctor orders treatments by placing them in the patient record. Nurses perform the treatment. When the patient checks out of the hospital, the administrator adds up the costs for the tests and treatments and generates an invoice.
Draw a UML class diagram showing how you would model this domain.
Write an interface for a DAO that transfers patient records between a database and the PTS using transfer objects.