Create TWO superclasses that contain member variables and/or methods common to at least 2 subclasses
Create at leat ONE interface (gutless methods)
Diagram your new setup
Project worktime
WED 5 DEC
Sockets and streams
System resources and data streams as objects
MON 10 DEC
Final session
Careers in programming
WED 12 DEC
Final period normal class time
Bring a fully-baked final project, please!
Session guides
Guiding questions, objectives, lesson activities, and out-of-class assignment listings are available for each class session. Click "toggle full session guide" to view all the session's sections.
Wednesday, 5 September 2018
Return to Java objects and stacks
live_helpGuiding questions
What is an Object again? How do I structure member variables and methods into
a structure?
check_circleLearning Objectives
Renew fluent writing of the Java language
Demonstrate the basic operations on a stack: pushing and popping
Create a second class in addition to your tool model class. In the main method, create two instances of your tool objects. Set a member variable on each such that they can be differentiated when we oragnize them in our stacks.
Using the API reference linked here and in the resources section, create an instances of java.util.Stack. Use its push() method to insert each of your tool Objects into the stack. Then call pop() once to retrieve the most recent tool Object. Display on the console one of its unique member variable values.
Pop off the second object and show its unique attributes.
playlist_add_checkMid-week ToDOs
Make sure you have NetBeans setup on your home computer
If today's exercises were a struggle, revisit our Java CIT-111 modules and write some java code along with some of those tutorials to get your head back re-oriented.
sendProducts
An in-progress set of classes, one tool Object class, and one client class with the main() method.
cakeExtension exercises
Demonstrate each of the remaining methods in the java.util.Stack in the same main method we pushed and popped. Use printlns to show which objects have been manipulated, viewed, etc.
The application development cycle: interfaces/specs created and then coders implement those specs
Step back to the larger library design process: we want objects that do x, y, and z. We don't care how--might be several ways.
straightenNote card diagnostic
Write a method declaration for a method that takes in two integers, one called length and one called width. This method's name is createRectangle. The method returns an object of type String. Any class can access this method.
Study the code. Note that we do not have an implementation of PyramidPrinter.
Create a class diagram of the existing components of this package.
Create a new class called CoolShapeMaker. Implement the PyramidPrinter interface in this new class. This will mean writing the guts of one method.
In PrinterLand, create a new instances of CoolShapeMaker and test your implementation of this new method.
Comment your code using JavaDoc comment formats used by Eric in the exiting code.
Create a repository on GitHub to which you can push your code. Push the entire package patternprinting to your repo.
cakeExtension exercises
Continue building our class library of shape printers. Create a new interface called ParallellogramPrinter. It should define a method that takes in a base width and a height and returns nothing. Implement the interfaces method in a new class of your creation. Create a looping system for printing out a parallelogram of the specified size.
What is all this fuss about maps, anyways? How are they different from lists?
check_circleLearning Objectives
Create a tangible representation of a map with literal keys and String values
Implement an expedition planning tool that uses keys as attributes of a expedition
straightenNote card diagnostic
PART I: Using the Java API documentation, study the classes java.util.TreeSet and java.util.HashSet. Now write the method signatures of THREE methods that these two classes have in common.
PART II: Describe WHY these two classes have these three methods in common. Use your own words, please, but feel free to consult any documentation you'd like.
Choose a location to which you'd like to lead an expedition of some kind: scientific, recreational, exploratory, etc. The location doesn't need to be on Earth.
Create a set of attributes about this expedition to store in our map, such as: location name, duration, purpose, cost, crew size, resources required, etc. These are our data keys. Write each one on a 1/2 note card in PEN, tape an actual key to it, and tie that it to a value represented by a note card whose text is in PENCIL.
Study our sample code that shows putting and getting from a map, and iterating over a map's data using an iterator.
Write your own code that converts your physical keys and values to digital ones inside the Map object in your code. Use the put(K,V) method to store your data and the V get(K) method to show you can retrieve that data.
Build out a user interface which allows the user to look up a value in the expedition's map by typing in the appropriate key into the console. The user should be given a display of the possible keys so they know what to type.
Keep going: once you can hard-code map inputs and allow the user to view the data, build out your interface to allow the user to adjust the values of the various trip parameters and display those values.
Prepare for other students to run and share your code next week!
playlist_add_checkMid-week ToDOs
Continue building your expedition program, taking time to digest and read about Maps, Sets, and Iterators/ Iterables as you go.
sendProducts
Working, commented, and understood code conforming to the project step specifications in this document
cakeExtension exercises
Assume you are building a prototype of an expedition management service for some small, garage-style version of NASA. In this organization, there is a period of time in which an expedition's attributes can be adjusted. Once the mission directory locks the expedition plan, however, no further changes are possible.
Implement these business rules in your program such that your expedition map contains a key called "locked". Create a final String type variable that stores the value that this key must contain in order for the map to be considered "locked". Before any changes to the map are allowed, the program must check the value of this key. Locked maps must not be changed, and the user should be given a semi-friendly error message.
Create an option when a menu is displayed to the user to lock the expedition. If the option is selected, the program should insert the appropriate value into the key's value container to lock the set (or unlock it).
Implement a password access system on the locking mechanism from the previous extension idea. If the user wants to lock or unlock an expedition, a password must be entered. If you get ambitious, don't store the actual password Hard-coded in your program, take the hash of the password, store that, and compare the hash of a user-entered password with the stored hash of the actual password. You'll need to do some reading about hashing!
Create a method for the user to duplicate the keys in an existing expedition when creating a new one. Choose an appropriate method on your map for making this possible.
Navigate to java.lang in the java 8 API. Find the StringBuilder class.
Write three lines of java code: On line 1, create an instance of StringBuilder, store it in a variable called sb
Line 2: Call the append method on your object pointed by by sb. Append the characters "abc"
Line 3: Call substring() and pass in the value of 2. Store the result of this method call in a typed variable called res
listLesson sequence
Complete the notecard diagnostic
program objective
Write a program that contains a method called printMap that iterates over any Map passed into it and displays the Key/Value pairs.
The output of the method in this program that does the iterating must output a List containing all of the values that were looked up before they were printed.
program requirement 1
The incoming Map to the method called printMap must hold String types for both keys and values
The output type for this method must be a List of String objects. The list implementation is up to you
Testing
Test your method by passing in your Expedition map. Then in the calling method, receive the list that the mehod packs up for you and iterate over its values. Prove that the logic works
Package your expedition map into an object called Expedition that contains one member variable called expedMap. Make this member variable private with getters and setters
Post your Expedition object to your github. Update our upload index.
Go retrieve somebody else's Expedition map and test your code!
How can we design software that doesn't need to be completely rewritten when a new user interaction system comes out? (I.e. mobile computing, touch screens, web versus desktop app...)
check_circleLearning Objectives
Demonstrate object interactions using both the terminal as display technology and a GUI display system
You find the following Java of code on Stack Overflow:
java.awt.Event.shiftDown()
Would it be a good idea to use this same code in your AWT application? If not, write a more suitable method call on a more suitable class. DEFEND your answer in a sentence or two.
listLesson sequence
Get our simple AWT systems working using Elizabeth and Michael Faux's AWT guide.
Map out the class relationships involved in clicking a button
Diagram logic vs. presentation layer structures
Explore AWT/Swing project specification
sendProducts
Please design a program that meets the following specification
program objective
Demonstrate separation of concerns by writing a program that can interact with your vehicle object using the command line and the GUI
program requirement 1
Create a class that instantiates and then interacts with your custom Vehicle object using the command line
program requirement 2
Adjust your GUI (using AWT or Swing) so that it shows interaction with the object.