You are expected to spend 5-8 hours per week outside the classroom working on this course. Please don't come up short with this time commitment and fall behind!
Announcements
What are Attendance Credits?
Software | Off the Shelf (reusable java code) |
Obstacles | |||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Installing Java - on your LaptopImportant: We are using an open source version of the JDK (Java Developer Kit) in order to have the JDK bundled with JavaFX. If you download the JDK from Oracle (Java), you will not get JavaFX. For ease of ensuring both the JDK and JavaFX is installed on your system and will work when submitted, please follow these instructions. Installing Liberica JDK and IntelliJUse these instructions so that you install BOTH IntelliJ and JavaFX as a bundle. Formatting with output code (demos String.format & printf) ( video ) |
UML templates
Java starting templates
Reviewing Important Stuff from Previous DaysAbout the Scanner ClassScanner Class - Reading input from console There's a scanner reading issue when you read an integer or double and then a string; its got to do with the newline character; here's a fix: scanner and the newline issue Scanner Class - Reading from textfiles ( source ) ( words.txt ) |
![]() Obstacle Problems( rules )Why are we doing these obstacle questions?
|
|||||||||||||||||||||
Datafilescodes.txt -- ticket bar codes words.txt -- a dictionary of 172,710 words small.txt -- a small 7 word dictionary ingwords.txt -- 12,557 words ending in ing Great Stuff |
Reusable CodeRandom Number Generatorrandom.java -- a random number generator EQUAL method real-number-equals-method.java -- used to see if two real numbers are equal to each other askQuestion method (graphics only) askQuestion.java -- use when asking for integer input -- data validatiom Linear Search method linear search -- used to search an array of integers for a target Binary Search method binary search -- used to search an array of integers for a target BUT the array MUST be sorted Bubble Sort method bubble sort -- used to sort an array of integers Quick Sort method quick sort -- used to sort an array of integers isNumeric(str) isNumeric(str) -- used to determine if a string is a number Circle Class Circle( ) -- a Circle class Rectangle Class Rectangle( ) -- a Rectangle class Dice Class Die( ) -- a Dice class |
Class | Content | Tasks | Extras (most likely not on tests/exams) |
||||||
---|---|---|---|---|---|---|---|---|---|
18 |
Final Exam ReviewThe following 3 questions are big ![]() Solution: TestProgram.java Item.java Cart.java ![]() |
What we did in class today:Today we reviewed for the exam. |
|||||||
17 |
Mouse Events![]()
1. each time the mouse is clicked, draw a green circle with radius 20 centred at the mouse click location
Video 1702:
Mouse Events
(12:47 mins)
|
What we did in class today:We began by reviewing ArrayList. Next, we discussed standard mouse events and did a couple of exercises. Finally, we worked on the hardware store. |
|||||||
16 Wk 11 outcomes guide |
ExceptionsThe hierarchy of Exceptions in the Java programming language begins with the Throwable class – which comes from the Object class and is its direct subclass.
Can you throw and catch exceptions to make this program work seamlessly without crashing? Video 1200: Try & Catch (15:55 mins) Lecture 11.1: Catching Exceptions (30:43 mins) (Sam explains what exceptions are and how to catch them.) Lecture 11.2: Throwing Exceptions (10:43 mins) (This is the best way to handle unintended errors that might occur in your class.) |
What we did in class today: ( Mon Mar 25 2024 )
|
Inspiration & Amazing Thinking
|
||||||
15 Wk 10 Review Week |
ArrayList
UML MultiplicityPolymorphism & Interfaces (a.k.a. contracts)![]()
declared_vs_actual_declarations ![]() |
What we did in class today: ( Tue/Thu Mar 12/14 2024 )
|
Inspiration & Amazing Thinking
|
||||||
14 Wk 9 outcomes guide |
Abstract ClassesIn Java, an abstract class is a class that cannot be instantiated and is intended to be subclassed by other classes. The main purpose of an abstract class is to provide a common interface for its subclasses while encapsulating implementation details. Advantages of Abstract Classes
InterfacesIn Java, an interface is a type that defines a contract for the behaviour of a class. An interface specifies a set of methods that a class must implement, but it does not provide any implementation itself. In other words, an interface defines what methods a class must have, but not how those methods should work. Within the interface, you can declare any number of method signatures, but you cannot provide implementations for them.
![]()
Lecture 9.0:
Abstract Classes
(12:36 mins)
Lecture 9.1:
Interfaces
(17:22 mins)
Lecture 9.2:
Polymorphism Explained
(20:12 mins)
|
What we did in class today: ( Mon Mar 11 2024 )We introduced the concept of abstract classes and interfaces. The classes we've been dealing with so far are called concrete classes. Next, we discussed Polymorphism, which comes from the Greek and meansmany forms. PolymorphismIn Java, polymorphism refers to the ability of objects of different classes to be treated as if they are objects of the same class. Polymorphism is achieved through method overriding, where a subclass provides a specific implementation of a method that is already defined in its parent class. The correct method to be called is determined at runtime based on the actual object that the method is called on. Mixed Shapes (an example of polymorphism)
|
|||||||
13 Wk 8 outcomes guide |
Inheritance week 8 guideJava inheritance is a mechanism that allows a new class to be based on an existing class, inheriting all of its properties and behaviours. The existing class is called the superclass, and the new class is called the subclass. Inheritance in Java is achieved using the extends keyword, which specifies the superclass that the subclass is extending. The subclass inherits all of the public and protected properties and behaviours of the superclass, and can also define its own properties and behaviours.
Overloading ( In Java, method overloading refers to the capability of defining multiple methods in the same class or in a parent class with the same name but different parameter lists. That is, overloaded methods have the different method signatures.
Here's an overloading_example
Overriding ( In Java inheritance, overriding refers to the capability of a subclass to provide a specific implementation of a method that is already defined in its superclass. When a subclass provides its own implementation of a method that is already present in its superclass, it is said to be overriding that method. )
Video 800: Java Inheritance Explained (6:11 mins) Lecture 8.0: Java Inheritance (26:54 mins) Lecture 8.1: Overriding (20:37 mins) |
What we did in class today: ( Mon Mar 4 2024 )
Terminology
|
|||||||
12 Wk 7 outcomes guide |
![]() |
What we did in class today: ( Thur Feb 29 2024 )
|
![]() Solution: PizzaSolutionGUI.zip ( code ) |
||||||
11 Wk 7 outcomes guide |
![]() Video 700: Placing GUI Components (24:30 mins) Video 701: Event Handlers (21:16 mins) Video 702: Model vs View (27:43 mins) Video 703: 2-D Arrays (8:50 mins)
Video 704: Sparse Matrix Algorithm -- Triplet Algorithm (4:40 mins) |
What we did in class today: ( Mon Feb 26, 2023 )Today, we did a simon-says on the circle manager. We discussed Java based style sheets and used a stylesheet in the circle manager.GUIs with a GraphicsContextmore understanding about the Canvas and Graphics Context Circle Manager AppSpecifications Download the starter: starter.zip Solution: |
2-D Arrays - How to Set Them UpExample 1: ( code ) zipSparse 2-D ArraysA matrix is sparse if many of its coefficients are zero. Many large programs in nature can been represented by sparse arrays. sparsity = Example1: Walking through 2d Array
Example2: Triplet Worksheet |
||||||
10 Wk 6 outcomes guide |
GUI - Graphical User InterfaceA Baseball Pitch Counter![]()
![]()
|
What we did in class: Mon Feb 12, 2024We began by building two GUI apps. A pitch counter and a bank app. We discussed event driven handler routines and GUI component styling. Assignment #3 - Robots![]()
|
JavaFX CSS Reference GuideCSS Guide |
||||||
9 Wk 5 |
Draw a UML for ordering pizza.
UML
![]() class layout
|
What we did in class: Mon Feb 5, 2024We began by creating a UML for a pizza ordering app. Next, we implemented a pizza order app. Finally, we discussed next week's test, and introduced some more review flashcards. |
|||||||
8 Wk 4 outcomes guide |
![]() Draw a UML for a coin blueprint. UML ![]() class layout
Lecture 4.3:
Association (27:15 mins)
Lecture 4.4:
Static (22:40 mins) |
What we did in class: Thur Feb 1, 2024We began by creating a UML for a coin class. Next, we discussed piggybanks and created a UML for a piggybank that accepts coins. Finally, we discussed next week's test, and introduced some review flashcards. |
|||||||
7 Wk 4 outcomes guide |
Calling Constructors with
|
What we did in class: Mon Jan 29, 2024The class began with a discussion of Next, we displayed an array of circles. Finally, we used the rest of the day to catch up from missed topics on previous days. |
|||||||
6 Wk 3 outcomes guide |
Visualize an Array of ObjectsOwners & Pets![]() Create an Owner and a Pet class. Each owner has a name and is allowed to own ONE pet. The allowed pet species are dog, cat or mouse. Begin by making a UML for the Owner and Pet classes
Lecture 3.3:
Encapsulation (25:21 mins)
Lecture 3.4:
Interface vs Implementation (19:35 mins) |
What we did in class: Tues & Thur Jan 23/25, 2024We began reviewing what an
Next, we saw a demo of the A2-VendingMachine. We practiced making UML's with draw.io using the Pet project as an example. Finally, we used draw.io to make a UML for the RemoteToyHelicopter. Remote Helicopter Class![]()
|
|||||||
5 Wk 3 outcomes guide |
Classes vs ObjectsWhat's the difference between aClass and an Object Class:
Object:
Dice ClassBank Account Class( static class variables, for next account number )TV Remote Control DesignCreate a UML design for a TV remote control. Use draw.io or UMLet.
Video 201:
What is an Object (11:36 mins)
Video 200:
UML - Unified Modeling Language (6:53 mins)
Lecture 3.1:
Objects and Instance Variables (40:00 mins)
Lecture 3.2:
Instance Methods (24:51 mins) |
What we did in class: Mon Jan 22, 2024We began by defining the term Next, we created a histogram of 500 dice throws using the Die class. We watched a video on Neural Pathways, to emphasize how practice and reps affect our learning.The obstacle system was explained and the first obstacle program was given out in class. (i.e. OB3). The problem needs to be submitted back to the instructor in one week. The A2-VendingMachine today is a good example of the model and view concept. The next A2 assignment was assigned. Assignment #2 - Vending Machine![]()
|
The Value of PracticeDeveloping Neural Pathways Best Guide to UMLWhat is a UML diagram UML stands for Unified Modeling Language, and it is a standardized modeling language used in the field of software engineering to visualize, specify, construct, and document the artifacts of a software system. UML provides a set of graphical notations and a framework for modeling object-oriented systems. Drawing UML diagrams |
||||||
4 Wk 2 outcomes guide |
Static Methods
Static Methods ( pptx )
Method Overloading example
another example
Middle number of 3 Conversions Between DataTypesConversionsConversions Cheat SheetRecommended: Always read in data from the user as a String, then convert it to what you need ... String -> intString -> doubleint -> Stringdouble -> StringAlternatively, when converting to String .... why not use, String.format( ) Using Arrays
Video 40: User-defined Methods (10 mins) Video 41: Returning Information from a Method (7:15 mins)
Video 42: Guessing Game (12:35 mins)
Lecture 2.3:
Switch Statement (9:33 mins)
Lecture 2.4:
Do While Loop (12:05 mins) |
What we did in class: Tue Jan 16 & Thurs Jan 18, 2024We began by discussing static methods. Next, we defined the term Next, we discussed breaking up hard problems to solve into several smaller easier problems. We used an array ROTATE example to illustrate the point. We concluded by watching a word guessing game video. In W8 we produce our own word guessing game. |
|||||||
3 Wk 2 outcomes guide |
Control StatementsScanner's Secret Issue ( wrt to consuming the newline character left in the buffer )When using Scanner in Java to read input, you may encounter issues with newline characters being left in the input buffer, especially when switching between reading different types of data (e.g., reading an int followed by a double).
Here's an example: Scanner's Secret Problem JavaFX Graphics - with Circle( )This program uses pre-built classes and illustrates how to ... ![]()
Solution: ( code ) ( RandomCircles.zip ) Reading & Writing Text Files
Video 30: if statements with AND ( && ) and OR ( || )(12:28 mins) Video 31: if statements & boolean comparisons with >=, <=, !=, ==, >, < (5:55 mins) Video 32: Reading from Files (5:33 mins) Video 33: Writing to Files (4 mins)
Lecture 2.1:
If, While, Boolean (47:01 mins)
Lecture 2.2:
For Loop (15:11 mins) |
What we did in class: Mon Jan 15, 2023We began by reaching back to class 2 and introduced Java Arrays, using the Array flash card powerpoint file. This is a stack of flashcards which you should review over-and-over until you become strong in arrays. The Scanner class has a weird issue regarding reading ints and doubles. We discussed this issue and saw an example which illustrates what happens if you don't We began by discussing the syntax of DO WHILE. The DO WHILE loop is a good choice for validating input data. We did a Simon Says example where we used a Circle() class and a DO WHILE to generate random circles on the canvas. We then used a Rectangle() class to do the same thing. This example might help with A1-Arkanoid. Next, we discussed the SYNTAX of various control structures, like IF, WHILE, DO WHILE, and FOR. Lastly, we discussed the new worksheet(s). |
|
||||||
2 Wk 1 outcomes guide |
Strings & NumbersJava Strings ( pptx ) ( code ) Java Numbers ( pptx ) Scope
In Java, the scope of a variable or object refers to the region of the program where the variable or object can be accessed or modified.
Example 1: ( code ) ( zip ) Example 2: ( code ) ( zip ) Casting
In Java, casting refers to the process of explicitly converting a value from one data type to another.
( code ) ( zip ) Java Arrays
Below are flash cards with a lot of repetition to help you build and consolidate your understanding of Java arrays. Practice using the POWERPOINT file, running through these slides until you're knowledge of arrays is strong.
Array Flashcards ( pptx ) Documentation Standards
Video 20:
Java Documentation (11:19 mins) Video 21: String Functions (17:02 mins) This video begins discussing special characters, e.g. \n, \", \\, and + Next various string methods are demonstrated, e.g. toUpperCase(), toLowerCase(), .length(), contains(), charAt(), indexOf(), substring()
Video 22: Number Functions (2.5 mins) Lecture 1.4: Data Types (34:21 mins) Lecture 1.5: Strings (12:22 mins) |
What we did in class: Tue Jan 9, or Thur Jan 11, 2023We began by discussing string methods as well as common methods used with numbers. Block level scope was discussed. We fixed two programs that had scope error issues. Next, we discussed casting and where and when it is commonly used. It was emphasized that a good understanding of Arrays are essential to this course. The Array Flashcards should be mastered. We outlined the importance of good documentation and the minimum standards required for documentation when submitting your program. Packages are a good way to organize like-minded java files. Today's worksheet centers on mastering format strings found in printf and String.format( ) Today's Worksheets ( protocol )MATCH the sample session EXACTLY, then add a small piece of CREATIVE code. Assignment #1 - Arkanoid![]()
|
|||||||
1 Wk 1 outcomes guide |
Java Virtual MachineThe Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs. ![]() You have lots of choices when it comes to selecting an editor for creating Java programs. Mohawk College has chosen to use IntelliJ. Integrated Development Environment Software / Java - IDEs To install IntelliJ onto your laptop it's important to follow these instructions. Java - Output ( including graphics with JavaFX )
JavaFX Graphics
Video 100:
System.out.printf( "format string", data ) explained (11:22 mins) Lecture 1.2: Variables, Input, Output (34:58 mins)
Lecture 1.3:
JavaFX Graphics (27:48 mins) |
What we did in class: Mon Jan 8 2023We began by discussing what the JVM is and how to install it on your system at home. Next we reviewed data types, primitives versus objects. A special discussion took place about comparing variables by contrasting == and .equals(). We empathized that the term "class" means "blueprint" and "object" means "an instance of an class". Next, we discussed displaying output via, .print( ), .println( ) and .printf( ). We demonstrated how to accept user input using the Scanner class. A awkward adjustment was introduced regarding Scanner when reading integers followed by strings. We used the TipCalculator to demonstrate Scanner and the adjustment. Next, we ran our first JavaFX program called, the Happyface. We looked at simple drawing tools and then discussed starting templates. Next, we ran a program which imports images as well as a program which demonstrates animation with a ball rolling across the canvas. The expectations i.e. protocol, regarding worksheet submissions was discussed. The first two worksheets were assigned. |
JavaFX documentation |
Thursday 4p - 5p Rm: A012
Friday 12p - 1p Join Zoom Session 952 2737 7950 | PASS
Tuesday 10a - 11a Rm: I219
Wednesday 10a - 11a Join Zoom Session 952 2737 7950 | PASS
Friday 12p - 1p Rm: I227