The Object project

Creating a Java version of a material object--and share it!

Put your skills to good use by choosing an object that has some interesting behavior that you'd like to model (guitars, calculators, etc.), plan out your object, and then transform that plan into Java code!

Jump to a section

check_boxCore Project Tasks
extensionConceptual Core: Object Modeling in Java
bookResources and reference documents

Project Phase Guides

object project phase diagram looks_onePhase 1: Choose an interesting, highly "modelable" object
looks_twoPhase 2: Create a written object plan
looks_3Phase 3: Translate object plan into Java code
looks_4Phase 4: Write a "testing class" with a main() method
looks_5Phase 5: Document & share your work

Core Project Tasks


Create a class diagram that represents the state (member variables) and functionality (methods) of a single physical object


Translate a class diagram into a Java class (or set of classes) that models the behavior of the planned object through command-line interaction and contains no main() method


Create a class with a main() method which creates an instance of the modeled object and demonstrates all of its functionality.fixed



Module Learning Resources

Amazing gallery of past student object projects with building guides, code samples, screen shots, and commentary on class structure.

Class structure learning module: Reviews basic structure of any class in Java.



Conceptual Core: Object Modeling in Java

The object project is about designing two classes that work together:



Phase 1: Choose an interesting object

object project phase diagram

Brainstorm and choose to model an object that lends itself to being modeled in Java. As we know, Java classes are blueprints for objects, and those classes hold member variables and methods related to that object.

No good ideas yet? Explore the object project starter page for code and more discussion about object modeling.

Examples of solid object model ideas (click links to jump into the project seed page)

  1. Fog machine
  2. Fish tank
  3. A fish in that tank, or other animals
  4. A character in a game or story with special powers
  5. A bank or bank account
  6. A word game (hang man, test for reversibility, etc.)
  7. Electric guitar
  8. An Automated Teller Machine (ATM)
  9. Scoreboard or sports statistic generator
  10. A player of a particular sport

Examples of weaker object model ideas

  1. An entire video game
  2. A computer or computer-like device (mobile phones, game machines
  3. A computer screen
  4. An entire sport
  5. A rock, or any other mostly inert object that just sits there



Phase 2: Create a written object plan

object project phase diagram

Create a class diagram as we've done for weeks now that includes:

We have seen many such models in the course so far. Your class diagram should have these components, arranged in this order. You can be creative as long as it has the essential structure:

FogMachine class diagram with a helper class



Phase 3: Translate object plan into Java code

object project phase diagram

With a class diagram and some solid thought on your Object design, you're ready to code. Follow these guidelines as you do so:

  1. Create a package with an appropriate name. Inside that package, create two classes: one with your Object's name, such as Calculator. Create another class that will test that blueprint-like-class class by creating an instance of that object with the 'new' keyword. You can name this class something like CalculatorLand if your object is a Calculator.
  2. If you use code from any source other than your brain, please note those sources in your code as you go--Don't wait until the end of your project to try and add the citations later. Do it when you use it.
  3. Code your desired object in your class named that object (i.e. MissionControl). Create your member variables with appropriate types.
  4. Write the method declarations for each of your Object's methods. This means writing the method name, its access modifier, return types, and input parameters.
  5. Start coding the methods themselves after the structure looks good. Process the input parameter as needed, adjust member variables, and return the agreed value
  6. Add comments above every method and class describing what the method does or what the class represents
  7. Since your Object class is supposed to model an existing object, its variables and methods should NOT be declared static. We're making a new instance of your object, in which case the members and methods would no longer be considered static.



Phase 4: Write a "client class" with a main() method

object project phase diagram

Write a "client" class that makes and uses our object

Our client class, in this example the PartyLand class represents the larger application that uses our object. When we create an instance of a FogMachine with new and then use a FogMachine object by calling one of its methods, such as generateFog(), we are acting as the client of that object, This is represented in the analogy of a steel supply business which provides big, heavy stuff to its clients. Our object that we're modeling provides information to the class that calls its methods.

We can zoom into our PartyLand class and see how this is done.

FogMachine class diagram with a helper class

Phase Steps

  1. Create your client class with an appropriate name
  2. Compose a main() method in this class. In main, use the new keyword to create an instance of your modeled object. Store the reference that you receive from the object creation process (right side of the =) in an appropriately named variable.
  3. Using the dot (.) operator on your pointer variable to access the methods you wrote on your modeled object. Show the user what your object can do!



Phase 5: Comment, Package, and share

object project phase diagram

Wrap up and share your work by following these steps precisely!


Step 1: Check and Comment

Check over your code and make sure you have commented each method by describing what that method does. Make a note of where you create an instance of your modeled object

Here is an example of creating a DisasterSite object in MissionControl class.

comments in java code


Step 2: Locate your package's source code directory

We are going to package up the following three items in a single directory, and then compress that entire directory for posting to the shared drive.

  1. Your package and source code (*.java files)
  2. A digital version of your class diagrams (for your blueprint object and the client class
  3. A screen shot of your program's output and user interaction

Open the Windows file explorer program

To find the source director for your PACKAGE you need to first find the directory for your entire PROJECT. This is inside the "NetBeans Projects" directory, which is stored in the Documents directory for your Windows user. Navigate to the following location:

Netbeans Projects / [your project name] / src / [your package name]

You should see at least two .java files in this directory. You'll save the screen shot and class diagram in here, with the .java files.

Leave this directory open in Windows Explorer so you can prepare your package for uploading in two steps.

Note this example of finding the .java files for DonutLand

comments in java code


Step 3: Capture and properly save a screen shot of your program's output

Run your program with various user inputs to show your Object working.

java output

Use the Snipping tool built into Microsoft Corporation's Windows 10 operating system (click the "start" button and search for "snipping"). Your snipping should look something like this (with different colors):

java output

Once you are happy with your clipping, save the image into the directory with your .java files!


Step 3: Create and/or just save a digital version of your class diagrams into the same directory as your screen shot and java files

Use any program you'd like: MS Word, draw.io google doc extension--anything--to create an accurate and pretty class diagram of both of your classes: The modeled object and the client class

Save this file into the same directory as your .java files and screen shot

At this point, you should have your package directory looking like this: with .java files, a screen capture of your output, and a file or two of your class diagrams.

java output


Step 4: "Click and Drag" your package directory into your GitHub account

  1. Check to make sure you have a package directory that contains your .java files, your screen shot, and your class diagrams.
  2. Log into your GitHub account. When viewing your repository home, position a windows explorer / file explorer window next to your window with GitHub.
  3. Click "upload files" in one of GitHub's menu bars. This should bring up a screen that receives uploaded or "dragged" files and directories. Now drag your entire package directory from your local drive to your GitHub repository.
  4. Once the upload is complete, be thorough and check to make sure the uploads worked for each file. Remember, you can upload images and all sorts of files to GitHub. But only source code files and images will be displayed correctly when you click on them in your repo.
java output


Step 5: Make a lovely entry in our submission index

Because you have uploaded an entire directory to GitHub, the link you'll post in the tracking spreadsheet should be to the entire directory, not to any one individual .java file as you are used to from past projects.

HURRAH! You're done!


Extension Question:

For those of you who like object design discussions, respond to this prompt on a separate paper and include it in your Object Project hamburger

You are pitching your object model to a group of developers who have volunteered to help you continue building your object into a full-fledged application. Respond to their question: “How is using Java’s object model an appropriate choice for for representing the material object you chose?” (Hand-write answer on paper and include in hamburger, or feel free to type, of course.)