How to do Lab 1 like a pro? (This is the way you're expected to work through your labs and eventually your practical exams.)
-
We read through the entire problem statement and notice we need 2 java and 1 jsh file.
-
We can quickly set up our tabbed vim environment.
vim -p Point.java Circle.java maxDiscCoverage.jsh
-
Use
gt
to move to the right tab,gT
to move left. -
Saving files
Action Keystroke Save current file :w
Save current file and quit :wq
OR:x
ORZZ
Quit current file without saving :q!
Save all files (that are opened in multiple tabs) :wa
Save all files and quit :wqa
Quit all files without saving any :qa!
*Note: If a new file is empty, it will not be created the first time you try to save it. For that you will need
touch emptyfile
-
I want to create another file, how to do it without leaving vim?
:tabnew AnotherClass.java
-
I want to open all my existing java files into tabs immediately!
vim -p *.java
jshell> /open Point.java
jshell> /open Circle.java
jshell> /open maxDiscCoverage.jsh
jshell> List<Point> points = List.of(new Point(0, 0), new Point(1, 0))
points ==> [point (0.000, 0.000), point (1.000, 0.000)]
jshell> findMaxDiscCoverage(points)
$.. ==> 2
jshell> points = List.of(new Point(0, -1), new Point(1, 0), new Point(0, 1), new Point(-1, 0))
points ==> [point (0.000, -1.000), point (1.000, 0.000), poi ... 0), point (-1.000, 0.000)]
jshell> findMaxDiscCoverage(points)
$.. ==> 4
jshell> /exit
You probably saw this in the Level 5 jshell testcase which was not readily provided to you as a jsh file. You can make your own level5.jsh by removing all the jshell>
in vim. Then, you can automate testing using:
jshell < level5.jsh
Notice the tests always begin with the /open
command, if you don't load your classes in order (superclass before subclass), things may go wrong that was not a result of an error in your code but rather JShell misunderstanding your input.
You can do testing without the hassle of typing out any jshell commands like this:
Your level5.jsh will now look like this without the extra commands:
List<Point> points = List.of(new Point(0, 0), new Point(1, 0))
findMaxDiscCoverage(points)
points = List.of(new Point(0, -1), new Point(1, 0), new Point(0, 1), new Point(-1, 0))
findMaxDiscCoverage(points)
jshell *.java maxDiscCoverage.jsh < level5.jsh
-
Link to the official course repository, where you earn participation through contributions to Issues and Wiki, the instructions are pretty comprehensive on how to setup your local environment!
-
Always take note of LumiNUS Announcements for updates!
-
Linux Environment for Windows (WSL): https://docs.microsoft.com/en-us/windows/wsl/install
-
(macOS) Install Java 11 using Homebrew
-
$ brew update $ brew tap homebrew/cask-versions $ brew cask install java11
-
$ java --version openjdk 11.0.9.1 2020-11-04 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9.1+1) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9.1+1, mixed mode)
-
- (Best) Java IDE: https://www.jetbrains.com/idea/
Only use IDE for Projects, you need ample practice on vim for PAs.
- Java11: https://docs.oracle.com/en/java/javase/11/docs/api/
- vim guide
- If you want autocomplete in neovim (a more robust version of vim), try https://github.com/neoclide/coc.nvim
- Terminal Replacement for macOS: https://iterm2.com
- Make your zsh (macOS) look pretty: https://dev.to/abdfnx/oh-my-zsh-powerlevel10k-cool-terminal-1no0
- Extra practice 💫
Prerequisite: expect (this should be preinstalled in most linux distributions)
scp is used for file transfers and should be unnecessary for this course.
-
Download wrapper into the directory you want.
-
chmod +x wrapper
-
Usage
<path to wrapper>/wrapper <stu password> <plab password> <stu server> <plab server>
-
Create alias in
~/.bashrc
or~/.zshrc
filealias plab="./wrapper pass1 pass2 [email protected] [email protected]"
Use absolute path to wrapper instead of
./
-
Restart terminal or
source
your configuration file.
Login to plab
plab
Download Point.java
from plab server into your current folder
plab -d ~/Point.java .
Upload your local Point.java
into plab (why are you using this function?)
plab -u Point.java ~