Q: What is the best way to generate a random number?
A: You should use Random Class with a seed to generate a random number. Take a look at the class document or Project 3 for more information.
Q: What is seed and how should I get seed from command prompt arguments?
A: Seed is a number that you will pass to Random Class constructor to make sure you will get the same sequence of random numbers. It is useful to check the output of your program against a test-case. Take a look at Project 3 for more information.
Q: Which IDE should we use for this Lab?
Q: Is there any styling criteria in this course?
A: Yes, follow this address for more information: http://www.cs.fit.edu/~ryan/cse2010/style.html
Q: What is Check-Style and how can we add its plugin to Eclipse?
A: Checkstyle is an open source development tool to help programmers write Java code that adheres to a coding standard.
To Install plugin:
To Configure Plugin:
To Check the Style:
Improve the formatter & ease your work (Optional):
Q: What is refactoring?
A: "disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior" from http://en.wikipedia.org/wiki/Code_refactoring
Q: How can I configure code formatter in Eclipse?
To configure code formatter you need to open window->preferences in eclipse, then select Java->Code Style->Formatter. You can create your own profile or use this XML file that set up to meet styling criteria of this course. Just download the file, then click on import, go to the location that you've download the XML file and import it. you can click on Edit and change any of the settings to meet your expectation in code formatting.
Q: How do I format on save?
A: Go to Window->Preferences in eclipse, then go to Java->Editor->Save Actions. Check the boxes for Perform Selected Actions on Save and Format source code. You probably want all lines. If you want "clean-up" on save, click on Additional Actions, and configure it to the same settings as the Java->Code Style->Clean Up.
Q: How can I configure code clean-up in Eclipse?
A: Configuring code clean-up is exactly the same as code formatter except you will find setting in Java->Code Style->Clean Up. We prepared another XML for (Code Clean Up XML) for you so you can import and use it to fix most of the styling problems of your programs.
Q: Where can I find format specifier's format in Java documentation?
A: Internally, printf and other methods will use class Formatter to generate formatted output. Refer to Java documentation for this class (click on the link above).
Q: How can I use StdDraw or Picture class for a projects?
A: Download StdDraw.jar or Picture.jar, and add it to your project (by import, dragging, or copying it to the project folder). Do not add it to src folder. Then right-click on the file and goto Build path->add to build path.