Option 1: Using an IDE [Recommended]
Configure your preferred Java IDE:
I recommend InteliiJ but Eclipse and Netbeans will work too
I know that there are other IDEs out there for Java, but if you get stuck, the TA’s and the Professor be more proficient in helping you if using one of these IDEs
I also recommend using Java 11 as it opens up your options for this assignment
Create a new Project [Screen shots 1-3]
The new Project should follow either a “hello world” or “empty project” template
Name the project with this format for someone named James Gosling (without the brackets) [JGosling_Assignment1_S19]
If Prompted, create a Class named Main and include the main method
All three of the IDEs listed above will have very similar setup process
If you get stuck at this step, there are plenty of YouTube demos for creating a “Hello World” project in all three of the IDEs
If you are still stuck and now want to consult the Class Forum, consider including screen shots of the parts that are confusing. Be as descriptive as possible and include references the methods you already attempted.
Configure the Project [Screen shots 4-11]
The idea behind this project is to create an object of a class you will make, call somewhere between one and five methods and then you are done. Calling of the one to five methods and creating the object will take place in the main method. I wouldn’t worry about those steps until you are ready to run the program to test user input/output
If you look at the project directory [usually located on the left of the editor in most IDEs] you should see a folder named JGosling_Assignment1_S19 [if you are named James Gosling otherwise it should follow your name]. Inside is a folder named src and if you followed step one correctly, you should see a file named Main or Main.java. If you created a package during your setup, I would recommend using the default package. You should be able to just drag and drop the file and change/remove the package header from your file.
Copy over the two Java files included [Dictionary_Template.java, DictionaryTester.java] into that directory or you can try importing them using your IDE’s import settings.
Rename the File Dictionary_Template to Dictionary
Open up the DictionaryTester file and you might notice that your IDE is underlining everything in red. That’s because the Tester is using external libraries that your Project doesn’t know about. To fix this we will need to add a class to the class path of your project. In IntelliJ, put your cursor over one of the red junit keywords and hit “alt-enter” [works on Windows and Linux, needs to be tested on OSX] then a pop-up should appear. Click on “add junit 5.3 to classpath” If maven is setup properly, you should find “org.junit.jupiter:junit-jupiter-api:RELEASE” hit okay at the bottom of the window and you should be good to go.
If you are having trouble with your IDE adding Junit 5.3 to the class path, I will include the “jar” files and you can add them manually.
Now that Junit is included and Dictionary_Template is renamed to Dictionary, you are ready to go.
In the init method from the Dictionary Class, you should import all of your data from ENUMs to your local data structure. Do not process any user input here.
Running the Tester [Screen shot 12]:
At anytime when writing your program you can run the Tester. If you have completed the init and querryDictionary methods then the tester will serve to test how thorough your implementation is.
To run the Tester simply run the java file DictionaryTester. Again make sure you don’t handle any user input in the init method. You should also not process any user input in the querryDictionary method.
The score you receive from the Tester does not necessarily reflect your actual grade for the assignment. It is more of a scoring of your implementation from a thoroughness perspective.
Submitting the Assignment [Screen shots 13-16 ]:
If you look at your project from your Operating file browser, you should notice a folder structure as follows JGosling_Assignment1_S19/src/. This is good, but you will need to attach some documentation. Create a folder at the same level as src named documentation. In that folder You should include a write up describing your implementation. You may also include sample outputs from runs of your code as .txt files, screenshots or even .pdf files.
Once you have done your writeup and have compiled all of your files that you wish to submit, Archive the directory JGosling_Assignment1_S19 as JGosling_Assignment1_S19.zip. If you don’t have any Archiving software installed beforehand, I recommend installing 7zip for this step. To verify that you have properly zipped your project, try unzipping JGosling_Assignment1_S19.zip and you should see just one directory named JGosling_Assignment1_S19. Go into JGosling_Assignment1_S19 and you should see two directories called src and documentation there should be no loose files in the directory JGosling_Assignment1_S19. Once you have verified that the directory structure is correct, you should submit the JGosling_Assignment1_S19.zip file for grading.
Option 2: Using a Text Editor [Not Recommended]
Note: If you choose to use a Text Editor to complete this assignment, you will receive very little if any help on the various potential setup bugs you encounter. Also, first read the entire process for using an IDE before reading the Text Editor Instructions.
Step 0: Configure your Text Editor:
The sky is the limit here, I personally recommend using VS Code, but feel free to use Sublime, Atom, NotePad ++, Vim, emacs, nano, notepad, leafpad, really whatever you are most comfortable using.
The following instructions are going to be for using Linux/OSX. If you have decided to use Windows, there are a few changes you need to make in the commands.
Step 1: Loading the Documents
Create a Directory called JGossling_Assignment1_S19 [replace JGossling with your first initial and last name]
In that directory, create two more directories called src and documentation. In the src directory, copy over the Java files provided. The documentation directory will hold your writeup and any screen shots, .txt files and other files that might help describe your program.
Change the file Dictionary_Template.java to Dictionary.java. Create a java file for your main method (probably called main.java) which will solely be the driver for your program (should be less than 20 lines excluding documentation).
In your Dictionary.java file, fill out the two methods init and querryDictionary without handling any user input, that should take place in another method.
For the Enumerations, they can be placed in the Dictionary.java file, or another file if you wish just make sure you only access them once (for loading).
Feel free to add more classes and methods as you see fit.
Arguably, this is the most difficult part, it is not too late to revert back to the IDE way of handling the project.
I have played around with Junit5.3 in the terminal and have found a way to get an output, it is not pretty but it is something.
First, you need to compile all of your java files, the javac command is your friend here. The command I run from the src directory level is: $ javac -classpath "lib/*" *.java -d "bin/"
For this to work, you need to place all the necessary .jar files that Junit and potentially your program needs in the lib directory which should be in the src directory. This will compile all of your java files into .class files in a directory named bin.
That wasn’t so bad, but wait, what do we do with all of these class files? Let’s start with the simplest run, running the driver class you made. Assuming you named it Main.java you can run the compiled class file from src with: $ java -cp lib/*:bin/ Main
Now, let’s say that you are feeling like you handled every test case scenario and want to verify your “thoroughness.” Now, when I run the unitTester through intelliJ, the IDE runs this command: $ /usr/lib/jvm/jdk-11.0.1/bin/java -ea -Didea.test.cyclic.buffer.size=1048576 -javaagent:/snap/intellij-idea-community/114/lib/idea_rt.jar=40979:/snap/intellij-idea-community/114/bin -Dfile.encoding=UTF-8 -classpath /snap/intellij-idea-community/114/lib/idea_rt.jar:/snap/intellij-idea-community/114/plugins/junit/lib/junit-rt.jar:/snap/intellij-idea-community/114/plugins/junit/lib/junit5-rt.jar:/home/ $USER/.m2/repository/org/junit/platform/junit-platform-launcher/1.4.0-M1/junit-platform-launcher-1.4.0-M1.jar:/home/ $USER/.m2/repository/org/apiguardian/apiguardian-api/1.0.0/apiguardian-api-1.0.0.jar:/home/$USER/.m2/repository/org/junit/platform/junit-platform-
engine/1.4.0-M1/junit-platform-engine-1.4.0-M1.jar:/home/
$USER/.m2/repository/org/junit/platform/junit-platform-commons/1.4.0-
M1/junit-platform-commons-1.4.0-M1.jar:/home/
$USER/.m2/repository/org/opentest4j/opentest4j/1.1.1/opentest4j-
1.1.1.jar:/home/$USER/.m2/repository/org/junit/jupiter/junit-jupiter-
engine/5.4.0-M1/junit-jupiter-engine-5.4.0-M1.jar:/home/
$USER/.m2/repository/org/junit/jupiter/junit-jupiter-api/5.4.0-M1/junit-
jupiter-api-5.4.0-M1.jar:/home/$USER/.m2/repository/org/junit/vintage/junit-
vintage-engine/5.4.0-M1/junit-vintage-engine-5.4.0-M1.jar:/home/
$USER/.m2/repository/junit/junit/4.12/junit-4.12.jar:/home/
$USER/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-
1.3.jar:/home/$USER/IdeaProjects/TestProject/out/production/TestProject com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 DictionaryTester
Now, I would urge you to consider Going to the IDE method again, at this point we are not learning about Java and Data structures, we have entered into learning a bit of Bash and how to use the java command.
After a bit of experimenting, I was able to trim down that command to something more reasonable (Make sure you have all the jars in the lib directory first): $ java -class-path lib/*:bin/ com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 -junit5 DictionaryTester
In my opinion, what Junit gives you is relatively hard to read, but if you look carefully near the end of the output, you should see these three lines:
Assuming the implementations were not hard-coded specifically for the test cases
Total Score: X
Total Extra Credit: Y
Where X and Y represents real numbers representing your UnitTest Score.
I would still encourage you to run your program with an IDE for the unittest, the experience tends to be much nicer and the IDE will tell you what was expected and what was received when running your program.
Simply follow step 4 from Option One