Project Seeds for Object Modeling

Examples of a few fully-baked object projects and some seed ideas

Project Digestion Activity

Familiarize yourself with class structure and the Object Project by digging into and dissecting one of these past student projects. Print off the lab guide and read the instructions. Then complete the lab.

bookPrinter-Friendly dissection activity guide (PDF)

mode_editEditable dissection activity guide (Open office document -- may look funky in MS Word)

  1. Choose one of the past student Object Projects on this Object Project Starter Seeds page. Best to not choose a fixer-upper for your first time through this lab
  2. Read the code for the project carefully
  3. Create a class diagram below of the two classes associated with each project: one that acts as a “blueprint” object and the other which holds the main() method and actually instantiates the object with the new keyword
  4. Diagram method calls in the space between the two classes
  5. Tackle the summary activity

Starter Seed User Guide:

The ideas in this guide are to stimulate your own creativity as a Java programmer. Some of these projects were completed by past CIT111 students, others are technologyrediscovery.net originals, and still others are just sketches of ideas Eric thought up to help in brainstorming.

Review any or all of these, but only build on other object projects to the extent your skill level requires. Challenge yourself! Avoid mushy brains!

COPY AND PASTE BAN DELCARED ALL ACROSS THE LAND! Copying and pasting during this project will turn your brain to mush! Each line of code must be your own, even if you use others objects as inspiration--even very direct inspiration.

Share the names of the authors of code you use in your project! Building with others is best when we can be honest about what work we contribute and which work we are building upon--since we're all building on previous components.


Past Object Project Index & and project commentary

Project Skeletons

These seeds provide you a basic class outline and some diagrams to get you started. If you are feeling less confident with this project, explore these first. Try writing a method or two.

videocamSkeleton: Fog machine (See photo Above)

Past Student Projects--In solid shape

Previous CIT111 Students have treaded in your steps before, and these are their tales. Remember to review the suggested revisions!

directions_boatSong object array storage
directions_boatFish Finder Simulation
functionsBasic math operations calculator
androidArtificial intelligence conversation simulator

Past Student Projects--More Complex

These coders immersed themselves in Java and worked for many hours outside of class. Many of them also had experience programming prior to CIT-111. Reading code that is more complex than you can currently write will train your coding senses.

directions_runBase numbering system converter
directions_runSuperhero character generator
gps_fixedInterstellar travel flight plan generator
bluetooth_connectedBlueTooth speaker connection simulation

Fixer Upper Projects

To transform one of these objects into your project, review the code and identify weaknesses in the code and correct them in your new design. This is a great exercise.

computerFixer Upper: PC Customizer
gamesFixer Upper: Primitive Score Board
perm_phone_msgFixer Upper: Cell phone repair ticket system


videocam

Skeleton: Fog Machine Model

A fog machine is ripe for modeling in Java! Fluid levels can be tracked with member variables, a super cool fog machine would have a blast intensity. The photographed machine has a 20-second blow timer, which can be modeled using the Java time objects.

STOP and read the code for the two classes linked below.

How the getFluidPercentLevel method works

Note the method called getFluidPercentLevel in the FogMachine class. This method allows a coder using this class to ask the object for the percent of its fog tank which contains fuel. This is a calculated value using the two private member variables: MAX_FLUID_ML and currentFluidLevel.

codeLink to the FogMachine Skeleton in our class GitHub repository

codeLink to the FogMachineLand Skeleton in our class GitHub repository

Ideas for continued building

  1. The FogMachine class is waiting to have additional member variables and methods that do something with those member variables added to the skeleton. Remember, you are in computer land, so our fog machines can do all sorts of interesting and odd things--like blast super healing fog rays onto ill folks, curing them forever! Certainly the class needs a method to simulate the blowing of the fog. Perhaps another to change the fog spray intensity. Maybe a method to refill the machine?
  2. Create an additional device that might be used in a party, such as a DiscoBall or a SpeakerSystem. Since all objects are created in FogMachineLand, you'll write the blueprint classes without any static member variables or methods, and then create an instance of those objects with the new keyword in the main() method of FogMachineLand. We can simulate a par-tay!

Sample FogMachine object code skeleton

Sample FogMachineLand code skeleton

Remember, this is the class that tests the methods on the FogMachine, so it must create one--with the new operator!

arrow_upward


directions_boat

Completed Project: Object-based array storage

This lovely Object Project creates Song objects and stores them in an array. This is more like a skeleton project in that there is no ability of the user to edit the song's data--it's all hard coded. The layout is simple and clean--very much worth studying

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Create the ability for the user to input data that gets dumped into the member variables on the Song objects. Right now, these are all hard coded in the Java--which is not very useful. You'll want to consider using a for() loop or while() loop for controlling user input. Create a new Song object each time the user requests to enter a new song.
  2. Add to the Song class such that the song has methods, such as playSong() that simulates playing the song by printing lyrics out to the console.
  3. Use a second array to organize a playlist of songs in an interesting order. Getting user input to make this playlist is a little tricky!

Program Output Screen Capture

arrow_upward


directions_boat

Completed Project: Fish Finder Simulation

A simulation of a fish finder checking various depths for fish. No user input--only timed calls to various methods

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. The method names in the class, such as waterTemperature need to be renamed to names that are action oriented, such as getWaterTemperature. This would be an appropriate name since the method's guts creates a random number within a reasonable range to simulate the reading produced by an actual water temperature sensor.
  2. Implement a user menu system so that the user can choose a depth to ping, or set search mode, fish type, etc. This is our classic case for a while()-controlled block of code.

Program Output Screen Capture

arrow_upward


functions

Completed Project: Calculator

A very technically useful tool for implementing basic mathematical operators on operands that are gathered from the user via the command line. A very neat and tidy example of a solid Object Project.

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Look up and learn about the modulo % operator in Java. Add this operator to the program and explain to the user what its results mean.
  2. Explore the java.lang.Math class and implement some other neat mathematical functions, such as rounding, absolute values, exponential notation, and others.

main() method in testing class:

Tyler did a great job of separating the functions of the Calculator class with the testing operations of the main() method in CalculatorLand. Note the use of Double.parseDouble() to convert what the user enters on the keyboard into numbers the Calculator object can process.

It's main()'s job to pass correctly typed data to the methods on Calculator. This model is important for your design considerations: the methods on your Object should be explicit about how to get the data into a form that it can accept. Perhaps you write methods that can parse a String into an int or double numeric value itself?

Program output screen capture

arrow_upward


android

Working Foundation: AI Simulation

Scarlett is the artificial intelligence object name which has one method called knownInformation. The class AI is responsible for holding the main() method where the program begins execution. It's job is simple: create a new instance of the Scarlett class and call the one method on that object.

This class, however, doesn't have any member variables. Rather, the one method might more appropriately be named something like holdConversationWithUser since the method contains a while loop which asks the user to ask theScarlett object questions.

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Write member variables that allow the Scarlett machines store information about itself, such as its model number and brain version.
  2. Create methods that allow the user to ask the Scarlett objects math questions and get the answer returned by that method.

Program Output Screen Capture

arrow_upward


directions_run

Completed Project: Base numbering conversion system

This base number converter system allows the user to specify a counting base (2 = binary, 10 = our familiar decimal system, and there are others) and convert numbers of their choosing between the base systems. Read about the radix/base system on Wikipedia. The system also can quiz the user on his/her/their conversion skills.

This class uses the Java concept of "extending" a class which means to bake in a "parent" class's code into its child class. This helps us reuse code and is called called inheritance. Read more about inheritance in Java at Oracle.

codeLink to the full object code in our class GitHub repository--the project are the three files with the word "base" in their title.

Learn about all the cool code by reading the through and extensive javadoc documentation for this application. You can make your own java docs, and it's easy since NetBeans bakes in the JavaDoc generator tool! Learn more about how this works through the Javadoc documentation documentation.

luke ross

Author Bio:

Luke Ross is a Sophomore Computer Information Systems Major at CCAC and recent alumnus of North Allegheny High School. Although this is his first Java project, his background in programming includes several semesters of C++, which Java echoes in many respects. He has plans of transferring to PITT for a Bachelor’s Degree in Computer Science. Outside the IDE, Luke enjoys volunteering as a drummer for his church’s worship team, playing chess, going to the gym, learning the guitar, and petting his cat.

Ideas for continued building

  1. Learn about the base/radix system! Figure out how to convert basic numbers from 0 to 100 into binary and represnt those digits in base 10 numerals. This will allow you to edit the code in a logical way
  2. Improve the quizzing system to provide statistics on the number of completed questions and the number correct.

Program Output Screen Capture

Base converter screen shot

arrow_upward


directions_run

Completed Project: Character Generator

In addition to some beautiful ASCII art, Derek created an object that models a super hero with powers that can be set and viewed through an interactive command line menu. Attributes of the character are stored in member variables.

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Build in another few attributes to the system, such as speed in flight. Create necessary member variables
  2. Create a character battle class that simulates two created characters engaging in some kind of competition
  3. The system of calculating attribute points needs some attention--it seems once you earn 25 you stay there
  4. Try your hand at some additional ASCII art!

Program Output Screen Capture

arrow_upward


gps_fixed

Completed Project: Interstellar travel flight plan

Ivan created a rather complex and quite impressive application which simulates rocket travel in two dimensional space and generates a location report based on inputted journey parameters such as launch angle (azimuth), velocity, and time.

He started building a graphic user interface to render the flight paths graphically. This is not yet functional -- ripe for the creating!

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Add the ability for the user to enter new travel vectors to the initial one. Print out the locations to nearby planets as currently implemented, and add a few waypoints of your own.
  2. Create an alert function that notifies the user when the ship enters a certain bound around a known planet.

Program Output Screen Capture

arrow_upward


bluetooth_connected

Completed Project: Blue Tooth Radio Simulation

This object employs extensive chained and nested logic blocks to control the user experience and yield the modeled behaviors of the blue tooth radio. Options are modeled that allow the user to connect the BlueTooth device to a speaker system.

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Add new radio functionality methods such as scanning for stations. You'll need to work carefully to integrate this functionality into the logic blocks that control the user input and menus. Great project!

main() method in testing class:

Study the following chunk of code from Mason's BlueToothRadio class: a while() loop is used to control code that gathers user input and calls appropriate methods on the class. In this case, the main() method is inside the BlueToothRadio class. In this sense, the BlueToothRadio object is testing and interacting with itself. This is not a preferred design pattern, but works for a small class such as this to illustrate the modeling concept.

Program Output Screen Capture

arrow_upward


computer

Needs-Some-Work Project: PC Customizer

This class is a Fixer Upper. The basic idea of storing data about a computer in member variables is solid, but the execution needs work.

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Refactor the code to avoid creating a buffered reader in each method that is called to fill in a member variable

Program Output Screen Capture

arrow_upward


games

Completed Project: Basic Score Board

A starter class for displaying game statistics

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Right now, the system doesn't take in meaningful user input. Create a more robust way of adding points to each team for various events. Perhaps create a method for determining point amounts by play

main() class

This code snipped shows the main() class in this project creating a ScoreBoard object--which is exactly the structure we want. The class we program needs to act like a blueprint for creating an instance of the object.

Program Output Screen Capture

arrow_upward


perm_phone_msg

Completed Project: Cell phone repair ticket system

Greg created a command-line interface for registering a repair ticket for a cell phone. He uses a Scanner object to gather information from the about the phone such as type and insurance plan.

The CellPhoneRepairTicket class consists mostly of private member variables with public methods for writing the values of the member variables, and reading them: the so-called getter (getting a member variable's value) and setter (setting a member variable's value) methods. The main() method's job is to create the object with the new keyword and retrieve values from the user and write their value to the member variables.

Read the main() method and determine the function of the getInfo variable. [Pause--go read the code] It stores the user's input and is used to pass the data into the setter methods, such as public void setRepairShop(int repairShop), whose job it is to place the value passed into the method into the member variables. This is a poorly named variable since it doesn't describe what the variable's function is: to temporarily store the user's inputted text for sending to the setter methods. You can think of a more useful (readable) name, I'm sure.

codeLink to the full object code in our class GitHub repository

Ideas for continued building

  1. Note the main() method is actually inside the class CellPhoneRepairTicket. Move this method to a new class called something like CellPhoneRepairTicketLand. There will be no static methods at all in the CellPhoneRepairTicket class.
  2. Build a Ticket object that can be stored in an array such that the system can ask the user for multiple service tickets, store each one, and retrieve any ticket the user requests to view. You could start modeling the ticket as a single String value, so each String object would be one ticket. You'll then want to use a flow control statement like a while() loop to allow the user to enter multiple tickets.

Program Output Screen Capture

arrow_upward