IB CS Java - for the Core Syllabus for exams in 2014
Introductory
Comments by Dave Mulkey , Germany, Aug 2012
These sample programs run in Processing,
a free Java IDE. They require a bit of conversion (not
very much)
if you wish to run them in a standard Java environment. Please read
the Introductory Comments
if you are unsure how to use this site. If you are new to
Processing, you might want to read
this page.
-
Computation - calculation,
decisions, repetition
-
Data - input, output, storage, processing
- Input and Strings
Cafeteria
Prices , Overdue
Books (dates)
,
ISBN
Validation (String character functions), String Notes and Practice
Matching
Birthdates (with format checking) , Mixed Up
Letters (String functions) , Encryption
- Arrays (linear)
Appointments ,
CD
list (search in array)
, CD List 2 (sorted)
,
Bookstore
(parallel arrays), DataList (GUI)
Queue - uses an
ARRAY to store a Queue of names
- Collecting and Saving Data
eMail
Addresses , eMail 2 (saving to disk file) , Saving
Prices (write to disk file)
- Objects for records and Collections
Dance
Name List (vector
collection) , Check-out
Trip List (Array of
Objects)
- 2D
Arrays
Tic Tac Toe
, Kings (GUI) ,
Ski Hotel
, 2D
TicTacToe (with GUI Buttons) , Game
Of Life (simulation)
- Sorting and Searching
Test Score
Stats (sorting)
, Primes
(searching) , Binary
Search , Bubble
Sort
Notes about sorting,
with illustrations and demonstrations
OOP Samples
They following programs demonstrate the use of OOP techniques.
IBIO
Test - code for the IBIO commands in JETS
Fractions - a program
to add fractions which are stored as Objects
Blackjack - a simple card
game simulation, using a CARD class
GUIdice - a dice
simulation with OOP techniques (only works in Processing ver 2 - not in ver 3)
Stack - uses a STACK
stored in a Linked-List to reverse a list of words
BinaryTree -
alphabetical binary search tree
You may find it easier and/or more satisfying to write OOP code in BlueJ,
which clearly shows separate classes and connections between them.
If you do switch to BlueJ, keep in mind that it uses STANDARD Java,
and is missing some of the Processing commands that make things easier.
Most of your code will work the same, but you will need to write
standard class headers and a main method.
GUI, Graphics and other Interesting Commands
You may find the following demonstrations useful for project work.
These examples are presented in Processing programs, but you might
wish to use NetBeans
for project work, as it makes lots of GUI and
other OOP construction faster and easier. Specifically, NetBeans
supports Swing components. Swing components are more complex
to use, but provide numerous helpful, advanced features.
Buttons
and Pictures - Uses AWT Buttons to display pictures (only works in Processing ver 2 - not in version 3)
NumList - input numbers and
store them in an AWT List box (only works in Processing ver 2 - not in version 3)
Quiz
Questions with Parallel Arrays - quiz questions with pictures (only works in Processing ver 2 - not in version 3)
Storing Data in Files
Email
List - saves names and email addresses in a disk file
By default, data files land in the Processing.exe folder
with the processing program - NOT in the Sketch folder
Dates
List - uses "loadStrings" and "saveStrings" to read and write
from a text file. The loadStrings and saveStrings commands
are sensible and store the .txt file(s) in the Sketch folder.