|
|
||
| You are here: | ||
|
Databases As far as the old programme (up to May 2005) is concerned, this was the only dossier idea in town. Students getting ready for 2006 and later are lucky (really!) because they can either use this very common type of application or branch out into new areas. For students who are not confident in their programming abilities, this may be a good choice because the design path is well-trodden.
I have encouraged my students to choose at least 4 but not more than 6 fields. More fields simply adds to the workload.. Storing a date might require us to first define a Date Class which is a complication we can well do without at this stage. I chose them to illustrate the use of different primitives, of course. If you choose to put it in BlueJ we can use the object in interesting ways on the workbench.
Right-button click the compiled Biscuit Class and select new Biscuit() - or whatever your object is. You have to give a name which is a valid Java identifier. The comments also appear in this create Object dialog. A red object instance appears on the bottom of the screen (the workbench). We can see (and use) the Public methods of the Class.
|
On this page: [ an object | the BlueJ Workbench | Properties ] The first task is to develop a class which represents an object or item that you wish to store data about. It could be:
Once the object is chosen, suitable fields have to be selected (fields, properties, any information you feel it useful to store to describe the object in question). As an example I have selected biscuits. It is too late now but I do realize this may cause some confusion with our friends in the USA and elsewhere. A biscuit is the British term for what you guys would call a cookie. Anyway I decided to keep the following information about biscuits:
Each field needs a type. This could be quite a complex decision, eg if we decided to store a date, but here we restrict ourselves to Java's primitive types. I have chosen the following types: // data members Here is my first attempt at coding the Biscuit Class , you can download it and put it in your favourite editor. Better still, choose your own object and code it. With the class as it exists now, we could use it in another program and test all the methods. However, BlueJ allows us to create an Object (instance) and to assign properties using the mutator methods. Try this:
Related: [ Java home | records home | next database page ] |
Dedicated to the Class of 2006: Angel |
|
|
|||
|
Questions or problems related to this web site should be addressed to Richard Jones who asserts his right to be identified as the author and owner of these materials - unless otherwise indicated. Please feel free to use the material presented here and to create links to it for non-commercial purposes; an acknowledgement of the source is required by the Creative Commons licence. Use of materials from this site is conditional upon your having read the additional terms of use on the about page and the Creative Commons Licence. View privacy policy. This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 License. © 2001 - 2007 Richard Jones, PO BOX 246, Cambridge, New Zealand; This page was last modified: July 29, 200823, 2008 |