Skip to content

Commit 3fcc7b7

Browse files
committed
attempted stretch assignment, testing not working yet
1 parent ba50895 commit 3fcc7b7

File tree

12 files changed

+640
-0
lines changed

12 files changed

+640
-0
lines changed

lesson_02/quiz_java/.gitattributes

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# https://help.github.com/articles/dealing-with-line-endings/
3+
#
4+
# Linux start script should use lf
5+
/gradlew text eol=lf
6+
7+
# These are Windows script files and should use crlf
8+
*.bat text eol=crlf
9+
10+
# Binary files should be left untouched
11+
*.jar binary
12+

lesson_02/quiz_java/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Ignore Gradle project-specific cache directory
2+
.gradle
3+
4+
# Ignore Gradle build output directory
5+
build
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
plugins {
2+
java
3+
id("org.springframework.boot") version "3.1.0"
4+
id("io.spring.dependency-management") version "1.1.0"
5+
application
6+
}
7+
8+
9+
java {
10+
toolchain {
11+
languageVersion.set(JavaLanguageVersion.of(21))
12+
}
13+
}
14+
15+
repositories {
16+
mavenCentral()
17+
}
18+
19+
dependencies {
20+
implementation("org.apache.commons:commons-text:1.10.0")
21+
implementation(project(":instructional-lib"))
22+
implementation("org.springframework.boot:spring-boot-starter")
23+
testImplementation("org.springframework.boot:spring-boot-starter-test")
24+
25+
}
26+
27+
28+
29+
application {
30+
// Define the main class for the application.
31+
mainClass.set("org.example.Lesson2")
32+
}
33+
34+
tasks.named<Test>("test") {
35+
// Use JUnit Platform for unit tests.
36+
useJUnitPlatform()
37+
}
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
package org.example;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
6+
import com.codedifferently.instructional.quiz.AnswerChoice;
7+
import com.codedifferently.instructional.quiz.MultipleChoiceQuizQuestion;
8+
import com.codedifferently.instructional.quiz.QuizPrinter;
9+
import com.codedifferently.instructional.quiz.QuizQuestion;
10+
/**
11+
* Lesson 2: Quiz on Git, IDEs, and Terminal Commands.
12+
*/
13+
public class Lesson2 {
14+
public static void main(String[] args) {
15+
QuizQuestion[] quizQuestions = makeQuizQuestions();
16+
if (!quizQuestions == null) throw new RuntimeException("Quiz questions cannot be null");
17+
QuizPrinter printer = new QuizPrinter();
18+
printer.printQuiz(quizQuestions);
19+
}
20+
21+
public static QuizQuestion[] makeQuizQuestions() {
22+
return new QuizQuestion[] {
23+
makeQuestion0(),
24+
makeQuestion1(),
25+
makeQuestion2(),
26+
makeQuestion3(),
27+
makeQuestion4(),
28+
makeQuestion5(),
29+
makeQuestion6(),
30+
makeQuestion7(),
31+
makeQuestion8(),
32+
makeQuestion9(),
33+
makeQuestion10()
34+
};
35+
}
36+
37+
private static makeQuestion0() {
38+
Map<AnswerChoice, String> choices = new HashMap<>();
39+
choices.put(AnswerChoice.A, "To make backups of files");
40+
choices.put(AnswerChoice.B, "To keep a record of changes over time");
41+
choices.put(AnswerChoice.C, "To delete unnecessary files");
42+
choices.put(AnswerChoice.D, "To run code more efficiently");
43+
return new MultipleChoiceQuizQuestion(
44+
0,
45+
"What is the main purpose of version control?",
46+
choices,
47+
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
48+
);
49+
}
50+
51+
private static makeQuestion1(): QuizQuestion {
52+
Map<AnswerChoice, String> choices = new HashMap<>();
53+
choices.put(AnswerChoice.A, "A duplicate copy of a repository that you own and modify");
54+
choices.put(AnswerChoice.B, "A temporary backup of the code");
55+
choices.put(AnswerChoice.C, "A tool for merging branches");
56+
choices.put(AnswerChoice.D, "A way to delete a repository");
57+
return new MultipleChoiceQuizQuestion(
58+
1,
59+
"What is a fork in Git?",
60+
choices,
61+
AnswerChoice.A // Replace `UNANSWERED` with the correct answer.
62+
);
63+
}
64+
65+
private static makeQuestion2(): QuizQuestion {
66+
Map<AnswerChoice, String> choices = new HashMap<>();
67+
choices.put(AnswerChoice.A, "Pull the latest changes");
68+
choices.put(AnswerChoice.B, "Commit changes locally");
69+
choices.put(AnswerChoice.C, "Push changes to the server");
70+
choices.put(AnswerChoice.D, "Write code directly in GitHub");
71+
return new MultipleChoiceQuizQuestion(
72+
2,
73+
"Which of the following is NOT part of the basic Git workflow?",
74+
choices,
75+
AnswerChoice.D // Replace `UNANSWERED` with the correct answer.
76+
);
77+
}
78+
79+
private static makeQuestion3(): QuizQuestion {
80+
Map<AnswerChoice, String> choices = new HashMap<>();
81+
choices.put(AnswerChoice.A, "git commit");
82+
choices.put(AnswerChoice.B, "git merge");
83+
choices.put(AnswerChoice.C, "git branch");
84+
choices.put(AnswerChoice.D, "git pull");
85+
return new MultipleChoiceQuizQuestion(
86+
3,
87+
"What command is used to combine changes from different branches?",
88+
choices,
89+
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
90+
);
91+
}
92+
93+
private static makeQuestion4(): QuizQuestion {
94+
Map<AnswerChoice, String> choices = new HashMap<>();
95+
choices.put(AnswerChoice.A, "Eclipse");
96+
choices.put(AnswerChoice.B, "IntelliJ IDEA");
97+
choices.put(AnswerChoice.C, "NetBeans");
98+
choices.put(AnswerChoice.D, "VS Code");
99+
return new MultipleChoiceQuizQuestion(
100+
4,
101+
"Which IDE is being used in the class?",
102+
choices,
103+
AnswerChoice.D // Replace `UNANSWERED` with the correct answer.
104+
);
105+
}
106+
107+
private static makeQuestion5(): QuizQuestion {
108+
Map<AnswerChoice, String> choices = new HashMap<>();
109+
choices.put(AnswerChoice.A, "Extensions");
110+
choices.put(AnswerChoice.B, "Debugger");
111+
choices.put(AnswerChoice.C, "Dev Containers");
112+
choices.put(AnswerChoice.D, "Source Control");
113+
return new MultipleChoiceQuizQuestion(
114+
5,
115+
"What feature allows developers to work from the same pre-configured environment in VS Code?",
116+
choices,
117+
AnswerChoice.C // Replace `UNANSWERED` with the correct answer.
118+
);
119+
}
120+
121+
private static makeQuestion6(): QuizQuestion {
122+
Map<AnswerChoice, String> choices = new HashMap<>();
123+
choices.put(AnswerChoice.A, "Editing and refactoring code");
124+
choices.put(AnswerChoice.B, "Browsing code");
125+
choices.put(AnswerChoice.C, "Playing music");
126+
choices.put(AnswerChoice.D, "Managing source control");
127+
return new MultipleChoiceQuizQuestion(
128+
6,
129+
"What is NOT a reason for using an IDE?",
130+
choices,
131+
AnswerChoice.C // Replace `UNANSWERED` with the correct answer.
132+
);
133+
}
134+
135+
private static makeQuestion7(): QuizQuestion {
136+
Map<AnswerChoice, String> choices = new HashMap<>();
137+
choices.put(AnswerChoice.A, "pwd");
138+
choices.put(AnswerChoice.B, "ls");
139+
choices.put(AnswerChoice.C, "cd");
140+
choices.put(AnswerChoice.D, "mkdir");
141+
return new MultipleChoiceQuizQuestion(
142+
7,
143+
"What is the command to list files in the current directory?",
144+
choices,
145+
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
146+
);
147+
}
148+
149+
private static makeQuestion8(): QuizQuestion {
150+
Map<AnswerChoice, String> choices = new HashMap<>();
151+
choices.put(AnswerChoice.A, "pwd");
152+
choices.put(AnswerChoice.B, "ls");
153+
choices.put(AnswerChoice.C, "cd");
154+
choices.put(AnswerChoice.D, "mkdir");
155+
return new MultipleChoiceQuizQuestion(
156+
8,
157+
"Which command is used to change directories in the terminal?",
158+
choices,
159+
AnswerChoice.C // Replace `UNANSWERED` with the correct answer.
160+
);
161+
}
162+
163+
private static makeQuestion9(): QuizQuestion {
164+
Map<AnswerChoice, String> choices = new HashMap<>();
165+
choices.put(AnswerChoice.A, "Change file or directory permissions");
166+
choices.put(AnswerChoice.B, "List files in a directory");
167+
choices.put(AnswerChoice.C, "Remove a file or directory");
168+
choices.put(AnswerChoice.D, "Copy a file or directory");
169+
return new MultipleChoiceQuizQuestion(
170+
9,
171+
"What does the command `chmod` do?",
172+
choices,
173+
AnswerChoice.A // Replace `UNANSWERED` with the correct answer.
174+
);
175+
}
176+
177+
private static makeQuestion10(): QuizQuestion {
178+
Map<AnswerChoice, String> choices = new HashMap<>();
179+
choices.put(AnswerChoice.A, "⌘ + Shift + T");
180+
choices.put(AnswerChoice.B, '⌘ + Spacebar, then type "terminal"');
181+
choices.put(AnswerChoice.C, "⌘ + Q");
182+
choices.put(AnswerChoice.D, '⌘ + S, then type "terminal"');
183+
return new MultipleChoiceQuizQuestion(
184+
10,
185+
"What is the shortcut for getting to the Mac terminal?",
186+
choices,
187+
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
188+
);
189+
}
190+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* This source file was generated by the Gradle 'init' task
3+
*/
4+
package org.example;
5+
6+
import org.junit.jupiter.api.Test;
7+
import static org.junit.jupiter.api.Assertions.*;
8+
9+
class AppTest {
10+
@Test void appHasAGreeting() {
11+
App classUnderTest = new App();
12+
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
13+
}
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties
3+
4+
org.gradle.configuration-cache=true
5+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This file was generated by the Gradle 'init' task.
2+
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format
3+
4+
[versions]
5+
guava = "33.4.6-jre"
6+
junit-jupiter = "5.12.1"
7+
8+
[libraries]
9+
guava = { module = "com.google.guava:guava", version.ref = "guava" }
10+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" }
44.4 KB
Binary file not shown.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
6+
zipStoreBase=GRADLE_USER_HOME
7+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)