"Advanced" Java Practice
Java has many advanced features that may take some effort to understand how to use properly (or even well :) but that require very little syntax. In most cases, they may not impact your design dramatically, but they can make your code much cleaner and understanding them well can help you think about design more deeply.
Here are ones we have discussed in class
For these exercises, practice Pair Programming (working closely with another student and sharing a single computer). To ensure both people try driving, switch the person who types on the primary computer every 10 minutes. You may use a second computer to look up documentation or search the Internet for solutions related to the exercises, but not to do your own work or socialize.
Roulette
Create a commit for each step below as your programming pair completes it.
- Create a
Factoryclass that manages theBetsubclasses. Initially, use an array (or perhapsList:) of hard coded subclasses. It should also handle printing out the menu of choices rather than theGameclass doing that.
- Change the
Factoryclass to use reflection instead of creating them directly. Initially, hardcode the strings in your collection instead of instances.
- Create a properties file that maps the complete
Betsubclass name to its odds and description (on one line separated by a comma for east parsing). Read this property file to determine which subclasses your factory should create.
Bins
Create a commit for each step below as your programming pair completes it.
- Create a new version of
runAlgorithmthat takes a Lambda that expects aList<Integer>and transforms the list in some way (e.g.,sort,shuffle, orreverse).
Browser
Create a commit for each step below as your programming pair completes it.
- Create a new version of the
makeButtonmethod that takes aStringinstead of a Lambda and uses reflection to convert that to a method. When the button is pressed the foundMethodshould be invoked.
Your Projects
If you have completed all of the practice steps, try updating some of your own code with some of these features (such as, enumerated types in Game or Cell Society, lambdas in Cell Society or SLogo, reflection in any program).
Submission
At the end of class, use Gitlab's Merge Request to submit your group's refactored code to the original organization repository for that project (i.e., lab_bins or cellsociety_teamXX). Make sure both people's NetIDs are in the title of your Merge Request.