CSE143 Winter 2003

Project 2

Shopping for Luck... At the Mall

Part B Notes

Due date details Overview Starting code

All starter files as a .zip

New! Oracle Mall and OracleUtils (1/31).  View README before using.

Written part Rules, advice, guidelines

Hints, tips, and corrections Please check here occasionally!

Part A/Part B contents Turn-in forms

 

Due dates: Part A due electronically Tuesday evening, January 28; paperwork due in class the next day.  Part B due electronically Tuesday Wednesday evening, February 4 5; paperwork due in class the next day.  (As usual, "evening" means 9:00pm).

Overview

Thanks to your fine programming, oracles have become a growth industry.  There are now many more than three, with more are appearing every day.  It's becoming very confusing to the average suppliant.  People need to know who is behind an oracle, what is looks like, what it does, etc. etc.  To put an end to the confusion, you have been commissioned to build an electronic one-stop-shopping Oracle Mall.  Consumers can select from a convenient list of available oracles and learn about them, as well as making requests and getting back omens and interpreting them... all  without leaving home.  All they need is a Java-enabled computer.  In addition, you want to cash in on the oracle craze yourself, by creating a sensational new oracle that everyone will flock to use.

The key to expandability is "plug-and-play".  It should be possible for new oracles and omen types to be created and to plug into the Mall without the Mall having to change its own programming.

Actually, we're already part-way there.  The framework of Project 1 allowed any Oracle/Omen pair to operate with only a minor change to P1Main, as long as the new classes followed the existing rules (as specified in the interfaces and accompanying documentation).

The descriptions below apply to both parts A and B, except as noted.  The main difference between the two parts is which oracles need to be created.  By the time you finish A, you will understand the framework completely.

Starting Code

All code, unless otherwise noted, belongs in a package named project2.  All Part A files are here in a .zip file. (If there are files for Part B, they are likely to be test files or helper code rather than required files, and they will be posted here later).  To avoid Bluej problems, you are encouraged to create the directory and place files in it before creating your Bluej project.   Don't let Bluej "fix" anything.  You can (and probably should) use any of the code you wish from your own solutions to Project 0 or Project 1, or from their sample solutions (see the main Homework page).

The OracleMall class provides a GUI interface by which a customer can select and invoke oracles; this file is provided, and you won't be able to hand in a modified version. 

You will need to write a simple P2Main which creates the Mall and supplies it with a list of available oracles.  Be sure to name the file P2Main.java and use the full, correct signature for main().

Supplied interfaces (you won't be able to turn in any of the three given interface files).  An interface IOracle is defined, with methods that every oracle must implement; similar to the on in Project 1 (although the new file has minor changes in comments and package name, the main difference is that getName() has been moved to a different interface).   The interface IOmen has the getName modification, and another one as well.  Instead of defining a method compareTo, it requires the standard Java Comparable interface.    In order to give customers more information about what they are getting, oracles and omens must all implement the new IPublicInformation interface

New interfaces.  The Oracle Mall requires that each oracle be both an IOracle and an IPublicInformation; omens must be IOmen and IPublicInformation.  To accomplish this, all oracles must be descendents of something new called PublicOracle (which must satisfy both IOracle and IPublicInformation) , and omens must be descendants of something called PublicOmen (which must satisfy both IOmen and IPublicInformation).  It is up to you to define these things appropriately.  Study OracleMall.java to see how these two new classes are used there.

Oracles and Omens. It is no longer necessary for each oracle to have its own unique omen type, though that is still allowable.  The oracle and omen classes themselves can have any name.  Objects that implement IPublicInformation (which includes oracles and omens) will have to have a getObjectName method.  The idea is that each instance of the class should have its own name.  This is in case two oracles of the same type open up separate shops at the Mall (like having more than one Starbucks, etc at the Mall.).  Or to cover the case when an oracle is called on more than once; each omen will have its own little name.

Written part

Some rules (for this project):

Some advice:

At this point in the course, a number of style or programming practice issues have been mentioned in class.  You have also seen examples of our code, and will have evaluated some of our code against the widely-used Sun standard..  Let these be reference points for the style you use in your own code.  This will be more of a grading point in Project 2 than in previous projects.

Part A specifics: Turn in all classes needed for the Oracle Mall to run a Luck Tester oracle.  Include a version of P2Main whose main method creates the Mall with 4 instances of Luck Tester (this code will be very short).   The oracle and its omen should operate according to the specs of Projects 0 and 1, but must fit within the new framework.  Also turn in written part I with the paperwork for Part A.

Part B specifics: In part B, you will not change the overall framework, but will add additional oracles and omens if needed.  From now on, omens will generally not be mentioned.  It is assumed that implementing any oracle implies implementing an appropriate omen.  Some of these rely on lecture material that we have not quite covered yet, so don't freak out!  Turn in the remainder of the written homework with the paperwork for Part B.

I. Text Searcher.  Operates according to the rules of Project 1, except that the user chooses the file to be searched.  The user can choose any file on his or her system.  (This is not as hard as it sounds -- look at the Java JFileChooser class).

II. Secret Prophecy Finder.  Operates like I, except for the way the text is searched.  The letters of the input request are matched to consecutive first letters only of consecutive words. Case, punctuation, and internal whitespace in the request are ignored.  The match may span lines.  Examples will be given. Important internal requirement: you may not use the approach taken in Project 1, where the whole file was read into an array and then the array was searched.  Search the stream as you read it line by line.  The omen returned by this oracle should include all of the lines of the file that participated in the match.

III. Secret Prophecy Finder Plus!.  Similar to II, except that a whole series of requests are processed, taken from a file, and the best results are presented. 

For II and II, details and examples will follow later.  There will be specifications about how much and what kind of error handling should be used, and what types of streams to employe.

There may be some kind of prizes for the people who can find the most surprising prophecies in well-known, unaltered texts!


Please read the turn-in forms carefully when they become available, including the fine print!  After submitting a form, read what comes back, too. Please make sure that you use the correct form for each part! Part A Turn-in form Part B Turn-in form

Buona Fortuna!

Hints, Tips, and Corrections

1.  The OracleMall as initially posted does not do anything with the URL available in the IPublicInformation objects.  An updated version of OracleMall is likely to be posted so you can test that feature.

New! Oracle Mall and OracleUtils (1/31).  View README before using.

2. [2/3/2003]: P2Main for part B: P2Main is should provide the Oracle Mall with instances of all of your oracle types (for most people, that will be four: Luck Tester (from Part A), and the three varieties of text searchers).  Actually, P2Main should provide more than one instance of each type, so the "Object name" can be checked.