Old version
This is the CS 112 site as it appeared on May 12, 2023.
Completing PS 4: Problem 4 without your own Card class
Overview
In PS 4: Problem 4,
we’ve asked you to use the Card class that you wrote for
Problem Set 3.
If you weren’t able to complete your own Card class, this page explains
how you can use a compiled version of our Card class in your
implementation of Blackjack.
Note: If you have a working Card class, there is no need to use
our version, even if you are concerned that your Card class may have
minor issues. We will be using our Card class when testing the code
that you are writing for PS 4.
Downloading and installing a compiled version of our Card class
-
If you haven’t already done so, create a
ps4folder for your work on this assignment, and download the starter files for this problem into that folder. -
Create a subfolder called
libwithin yourps4folder. -
Download the following file into that new
libfolder:
Card.jarMake sure to put this file in the
libsubfolder of yourps4folder. If your browser doesn’t allow you to specify where a file should be saved, try right-clicking on its link above and choosing Save as... or Save link as..., which should produce a dialog box that allows you to choose the correct folder for the file.Note that only
Card.jarshould go in thelibsubfolder. All of the other files for this problem should go in yourps4folder. -
In VS Code, select the File->Open Folder or File->Open menu option, and use the resulting dialog box to find and open your
ps4folder. (Note: You must open the folder; it is not sufficient to simply open the file.)The name of the folder should appear in the Explorer pane on the left-hand side of the VS Code window, along with the names of the starter files
Blackjack.javaandDeck.java.In addition, you should see the name of the
libsubfolder that your created above. If you click on the namelib, you should see thatCard.jaris inside that subfolder.(Note: Because
Card.jaris a compiled version of ourCardclass, clicking on the name of the file will not show you its contents.)
Running and testing your code without a random seed
If you install our Card.jar file in the way that we have outlined
above, you should still be able to run the program by highlighting
Blackjack.java in the list of files before using F5 to run the
program. Another option is to right-click on the name of the
Blackjack.java file in the Explorer pane and choose Run or Run
Java.
Running and testing your code with a random seed
If you install our Card.jar file, the process of testing your
program using a random seed will require that you enter different
Terminal commands than the ones that we provide in the assignment.
Here are the revised procedures:
-
As needed, open your
ps4folder by using the File->Open Folder or File->Open menu option in VS Code. (Note: You must open the folder; it is not sufficient to simply open the file.) -
If you don’t already have a Terminal pane at the bottom of the VS Code window, use the Terminal->New Terminal menu option to open one.
-
Enter the following command from the Terminal to compile your code:
javac -cp 'lib/*' *.java
If executing this command produces error messages describing bugs in your code, fix them, save the file(s) in VS Code, and try again. Repeat this process until your code compiles without any error messages.
-
Enter the following command from the Terminal to run your code with a random seed:
-
on Windows:
java -cp 'lib/*;.' Blackjack seed
where you replace
seedwith an integer. -
on macOS or Linux:
java -cp 'lib/*:.' Blackjack seed
where you replace
seedwith an integer.
Note: The two commands are almost identical, but in the Windows version there is a semi-colon (
;) before the period (‘.’), whereas the macOS/Linux version uses a colon (:). -
-
If you make any changes to your code, make sure to:
-
Save the changed file(s) in VS Code.
-
Recompile your code by executing the command from step 3 before you attempt to rerun the program.
-