In Chapter 3, the author designs a Day
class even though there are already perfectly good classes in the java.time
package. Which class could you use to represent calendar days?
Instant
DayOfWeek
ZonedDateTime
Three versions of the Day
class are presented in this chapter. What is this meant to demonstrate?
Consider the following classes:
public class Post { private Response studentResponse = new Response(); private Response instructorResponse = new Response(); . . . public Response getStudentResponse() { return studentResponse; } public Response getInstructorResponse() { return instructorResponse; } . . . }
Which of the following statements is true?
lab5
subdirectory of your personal repo, the other submits a file report.txt
in the lab5
subdirectory of your repo.cd ~/cs151 mkdir lab5 jshell
import java.time.*; Instant.now()What happens?
var newYear = ZonedDateTime.of(2000,1,1,0,0,0,0,ZoneId.of("America/Los_Angeles")); newYear.plusDays(1000)
/exitto exit JShell. Then copy the
Day.java
file from the oodp3code/ch03/day3
directory to the current directory (.
). Open the Day.java
file in jshell and construct an instance:
cd ~/cs151/lab5 cp ~/oodp3code/ch03/day3/Day.java . jshell /open Day.java var newYear = new Day(2000, 1, 1);What happens?
Day.java
had a toString
method. Edit Day.java
with a text editor of your choice. Add this method:
public String toString() { return String.format("%04d-%02d-%02d", year, month, date); }
Day.java
in JShell (with /open
) and try the previous command again. What happens?newYear.plusDays(1000)What happens? Why?
~/oodp3code
in the lab for lecture 2. Verify that's correct, and otherwise adjust the instructions. Or, if you've never done it, go back to lecture 2 to see how to do the cloning. mkdir ~/cs151/lab5 cp -R ~/oodp3code/ch02/mail ~/cs151/lab5 cd ~/cs151/lab5/mail javac *.java java MailSystemTesterWhat happens?
~/cs151/lab2/mail/keys.txt
java MailSystemTester < keys.txtWhat happened?
Q
, the program should have terminated, and you should get a prompt back. If not, hit Ctrl+C to kill the program and fix up keys.txt
bin
directory. In that case, run
java -classpath bin MailSystemTester < keys.txt
git status
. Scribe: What files do you see that should not be checked into the repo?c:\Program Files\whatever
that are meaningless on other systems.git rm --cached file
or git rm --cached directory
to remove any files that you want to suppress. The --cached
means that the files won't be deleted from your local directory.git status
again. What is the difference?.gitignore
in the ~/cs151
directory. (Note the file name has ten characters, including a period in the front.) Add the following lines:
**/*.class .project .classpath .settings(If you use IDEA or NetBeans, add whatever is needed to filter out those configurations.)
git status
again. What is the difference?git status
. If not, run git add
to add any files that you previously forgot to add. Then run git commit
and git push
cd ~/cs151 ls -aWhat happens?
.
and ..
directories are the current and parent directory. The .git
directory contains files that Git needs. You should see a file hw1scores.txt
. Don't mess with any of those. Then you should see seven directories hw1
, hw2
, lab1
, lab2
, lab3
, lab4
, lab5
. All in lowercase. No spaces, underscores, dashes, etc. There should be no other directories.git mv
to move a directory, and to tell Git what's happening. (If you just use mv
, then Git will cry loudly that the old directory was lost and it doesn't know the new one.) For example,
git mv "HW 1" hw1If there is a file that shouldn't be there at all, run
git rm
to remove it. This will remove it from your computer as well, so don't do that with files that should be in .gitignore
.