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+ }
0 commit comments