Description: This program outputs a message to the screen and exits.Objectives:
Project: Source:
- Create and run a simple Java program without doing much typing.
- Learn out program output.
- Start to understand packages.
- HelloWorld.java    view
Description: This program prompts for your name and then says hello to you.Objectives:
- Learn to do simple keyboard input using the Scanner class.
- Experiment with a class that has static methods.
Project:
Source:
- WhoAreYou.java    view
Description: The Rectangle class represents a single rectangle and knows its length, width, area and perimeter. Some of this information it will store as attributes, the remainder it will calculate when asked. TheRectangleTesterprogram has amainmethod to create (instantiate) severalRectangleobjects and call methods. It is used for testing and debugging. These classes are developed incrementally during the lecture case study to show how to develop incrementally.Objectives:
- Learn how to develop a simple class.
- Learn learn how to instantiate objects.
- Learn incremental development and testing.
Project:
Source:
- Rectangle.java    view
- RectangleTester.java    view
Description: A counter has-a count that can be incremented and decremented. The count can be set to zero. The value of the count can be displayed. Initially the value of the count is zero. An enhanced version of the counter can be initialized or reset to any value. It is also possible to increment or decrement the counter by any value. Objectives:Source:
- Practice developing a class from a description.
- Learn about polymorphism by using multiple constructors.
- Learn about overloading methods.
Additional example: This case study also included the Sheep class which uses a static variable count to keep track of how many Sheep objects have been created. The following Sheep class has two counters, a static one to keep track of the number of Sheep objects that are created and a non-static one that keeps track of the number of times a particular Sheep says Baa!.
- Counter.java    view
- CounterTester.java    view
- Sheep.java    view
- SheepTester.java    view
Description: An account at a local bank keeps the name of the person with the account, the account number (a string of characters), the beginning balance for the month, the current balance, the amount of all deposits for the month, and the amount of all withdrawals for the month. The person (through the bank) can make deposits to and make withdrawals from the account. The bank (client) will need to print all the information about the account as well as print the individual pieces of information about the account. At the end of each month the bank (client) will need to initialize the deposits and withdrawals to zero. Design anAccountclass for this specification. Objectives:Source: Source:
- Practice developing a more complicated class from a description.
- Discuss the software engineering process.
- Account.java    view
- AccountTester.java    view
Description: This case study develops three classes that illustrate flow of control for the three types of Java loop control structures: for, while and do-while. Objectives:Source: Source:
- Learn about loop control.
- Learn to use a debugger to examine flow of control.
- ForLoopTest.java    view
- WhileLoopTest.java    view
- DoWhileLoopTest.java    view
Description: A rational number has a numerator and denominator. Two rational numbers can be added, subtracted, multiplied or divided to produce a new rational number. A rational number can also produce its reciprocal. Rational numbers can be tested for equality. Rational numbers are stored in reduced form (i.e., common factors from numerator and denominator are removed). Objectives:Source:
- Develop more complicated classes.
- Pass objects as parameters to methods.
- Learn about object equality and the equals method.
- Implement an interface.
- Use the compareTo method for object comparisons.
- RationalNumber.java skeleton view
- RationalNumber.java    view
- RationalNumberTester.java    view
WordUtility class Description Develop aWordUtilityclass that contains static methods to perform the following useful functions on strings:Objectives:
boolean isVowel(char c)- returnstrueif the charactercis a vowel andfalseotherwise.int firstVowelPostion(String s)- returns the position of the first vowel insor-1ifsdoesn't contain any vowels.int firstBlank(String s)- returns the position of the first blank character insor-1ifsdoes not contain blanks.int firstOccurrence(String s, char c)- returns the first occurrence ofcinsor-1.int firstNonBlank(String s)- returns the position of the first nonblank character insor-1ifsonly contains blanks.int firstNonVowel(String s)- returns the position of the first character insthat is not a vowel or-1ifscontains all vowels.int numberVowels(String s)- returns the number of vowels ins.int numberNonVowels(String s)- returns the number of non vowel characters ins.Source:
- Become more familiar with the String class.
- Learn to develop static utility methods.
- Work with indexing in the String class in preparation for arrays.
- WordUtility.java    view
- WordUtilityTester.java    view
Description: Implement an ArrayUtility class, which is patterned after the Math class, containing static methods that perform various operations on arrays:public static void printForwards(int [] array); // outputs array public static void printBackwards(int [] array); // outputs array in reverse order public static int getSum(int [] array); // returns sum of array values public static double getAverage(int [] array); // returns average of array values public static int getMax(int [] array); // returns minimum value in array public static int getMin(int [] array); // returns maximum value in array public static int [] reverse(int [] array); //returns new array with elements reversed public static int [] clone(int [] array); // returns a new array with copy of array public static int find(int [] array, int target); // returns index of target in array // or -1 if not thereObjectives:Source:
- Practice with basic array manipulation.
- Learn important operations such as copying an array and searching an array for a particular value.
- Pass arrays as parameters to methods.
- Develop methods with array return values.
- Get more experience with the behavior of static methods.
- Understand the usefulness of method overloading.
- ArrayUtility.java    view
- ArrayUtilityTester.java    view
Description: The ClassList class holds information about students in a course. ClassList has the title of the course, the discipline, the course number, the name of the instructor, and the semester in which the course is offered. ClassList also contains a list of students enrolled in the course and their grades. In addition to the usual accessors and the toString method, ClassList has methods to add or remove a student from the course, to change the grade of a student, and to find the grade of a student given the student ID. Objectives:Source:
- Use an array of objects in a class.
- Develop a class from a more complicated specification.
- Practice with arrays.
- StudentGrade.java    view
- ClassList.java    view
- ClassListTester.java    view
Description: Reimplement the ClassList class using an ArrayList instead of an array. Objectives:Source:
- Learn about the separation between public interface and implementation.
- Use one of the Java Collection classes in a real problem.
- Practice implementing more complicated classes.
- StudentGrade.java    view
- ClassList.java    view
- ClassListTester.java    view
Description: Tic-tac-toe is a game played on a board (usually 3 x 3) by two players represented by 'X' and 'O'. The players alternate turns with 'X' always starting. The player whose turn it is, writes his/her symbol in an unoccupied square of the board. A player wins if a row, column, or major diagonal is fully occupied by the player's symbol. If all of the squares are filled without a winner, the game is a draw. Develop a TicTacToe class that keeps track of the playing of a tic tac toe game. (The game will not limit itself to a 3x3 boardsize, but will choose this size as the default.) The TicTacToe class keeps track of the board size, the state of the board, and the number of moves made so far. If the game is in process, TicTacToe keeps track of which player goes next. If the game has finished, TicTacToe has the winner ('X', 'O', or 'D'). TicTaxToe has the usual acceessor and toString methods. Finally, the TicTacToe class has a method:public boolean move (int x, int y)which makes the move specified by (x, y). If the specified move is valid (in range and the square is not already occupied), the method writes the symbol of the player whose turn is next into the square (x, y) and returns true. If the move was invalid, the method returns false and makes no changes in the state. (Of course, some other attributes will need to be updated when a move is made.) Objectives:
- Learn to work with two-dimensional arrays.
- Develop more complicated classes.
- Develop a class to be used later with a GUI.
Source:
- cs12.zip
- cs12skel.zip (project skeleton)
- TicTacToe.java    view
- TicTacToeTester.java    view
Description: The is-a relationship holds between two concepts when the first is a specialized instance of the second. That is, for all practical purposes the behavior and data associated with the more specific idea form a subset of the behavior and data associated with the more abstract idea. The Shape class holds the attributes that are common to all shapes, in this case a name and an area. However, the specific details of how to calculate the area is left to the subclasses. Hence, Shape is an abstract class. Objectives:Source:
- Introduce the concepts of inheritance and abstract classes.
- Develop subclasses that extend abstract and other classes.
- Use case studies to enhance understanding of these concepts.
- Illustrate class relationships such as inheritance, aggregation and composition using UML.
- Shape.java    view
- Square.java    view
- Circle.java    view
- Rectangle.java    view
- ShapeTester.java    view
Description: Searching means to find the position of a specified value in an array. Sorting is the process of rearranging a collection of items so that they appear in ascending or descending order. This case study develops two searching algorithms (linear and binary) as well as two sorting algorithms (selection and insertion) for arrays of int and arrays of Comparable. Objectives:Source:
- Practice with arrays.
- Understand the concepts of search and sorting.
- Introduce the binary search algorithm and order of operations.
- Learn the inner workings of the insertion and selection sorts.
- Learn to instrument code effectively.
- Introduce the concepts of number or order of operations.
- Search.java    view
- QuadraticSort.java    view
- Utility.java    view
- SearchSortTester.java    view
- Output view
Description: There are many ways to do the design. The solution presented here uses interfaces in which the mthods all no return value. Objectives:Source:
- Work with more complicated classes and interfaces.
- GameDriver.java    view
- GameInterface.java    view
- Game.java    view
- UserInterface.java    view
- UserScanner.java    view
Description: An applet is a Java program that is meant to be embedded on a web page. When the applet is activated (by clicking on its representation), the applet code is downloaded to the client's machine and executed. This case study develops two simple applets and experiments with their execution. Objectives:Source:
- Learn how to create an applet.
- Draw simple geometric shapes and use colors.
- Execute code from a web page.
- JAppletPrototype.java    view
- TestApplet.java    view
- BoxApplet.java    view
Description: A GUI or graphical user interface is a graphical component designed to interact with a user. You access most applications (JBuilder, your browser, your word processor, etc.) through a GUI. You start the application, a window comes up, and the application waits for you to do something. Generally you click on a button or pull down menu and select a menu item to get things started. After the application performs the command, it waits for another. Applications designed around a GUI are event-driven. This case study gives examples of different kinds of GUIs. Objectives:Source:
- Learn how event-driven execution works.
- Learn about basic GUI design.
- Experiment with event handling and listeners.
- Use a variety of visual components.
- SimpleWindowApplication.java view
- HelloApplication.java view
- ButtonApplication.java view
- ButtonPanel.java view
- ButtonPanelApplication.java view
- TelephoneKeypadPanel.java view
- TelephoneKeypadApplication.java view
- PushCounterPanel.java view
- PushCounter.java view
- ColorButtonPanel.java view
- ColorButtonPanelApplication.java view
Description: This case study develops a Tic Tac Toe game based on Case Study 15. The only new class is UserGUI. The GameDriver was modified to use this class. All of the others are classes are identical to the ones in Case Study 15. Objectives:Source:
- Learn how event-driven execution works.
- Learn about basic GUI design.
- Experiment with event handling and listeners.
- Use a variety of visual components.
- GameDriver.java    view
- GameInterface.java    view
- Game.java    view
- UserInterface.java    view
- UserGUI.java    view