-
Notifications
You must be signed in to change notification settings - Fork 29
Daniel Boyce lesson 02 pr completes typescript quiz and code for java port still need to configure project to run properly #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ca6cd22
chore:completed quiz with passing tests
cbda24d
chore:added functions and code for the quiz in java
Boyce007 7719d8e
feat:tried to get it working
Boyce007 d4884a1
Merge branch 'code-differently:main' into feature/lesson-02/quiz
Boyce007 a3e012d
fix: resolves gradle build issues
anthonydmays File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# https://help.github.com/articles/dealing-with-line-endings/ | ||
# | ||
# Linux start script should use lf | ||
/gradlew text eol=lf | ||
|
||
# These are Windows script files and should use crlf | ||
*.bat text eol=crlf | ||
|
||
# Binary files should be left untouched | ||
*.jar binary | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore Gradle project-specific cache directory | ||
.gradle | ||
|
||
# Ignore Gradle build output directory | ||
build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
plugins { | ||
// Apply the application plugin to add support for building a CLI application in Java. | ||
id 'application' | ||
} | ||
|
||
repositories { | ||
// Use Maven Central for resolving dependencies. | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
testImplementation libs.junit.jupiter | ||
testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
implementation libs.guava | ||
implementation project(":codedifferently-instructional") | ||
} | ||
|
||
// Apply a specific Java toolchain to ease working on different environments. | ||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
|
||
application { | ||
// Define the main class for the application. | ||
mainClass = 'org.example.Lesson' | ||
} | ||
|
||
tasks.named('test') { | ||
// Use JUnit Platform for unit tests. | ||
useJUnitPlatform() | ||
} |
162 changes: 162 additions & 0 deletions
162
lesson_02/quiz-java/app/src/main/java/org/example/Lesson.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
/* | ||
* This source file was generated by the Gradle 'init' task | ||
*/ | ||
package org.example; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import com.codedifferently.instructional.quiz.AnswerChoice; | ||
import com.codedifferently.instructional.quiz.MultipleChoiceQuizQuestion; | ||
|
||
public class Lesson { | ||
|
||
public static void main(String[] args) { | ||
MultipleChoiceQuizQuestion[] questions = makeQuestions(); | ||
for (MultipleChoiceQuizQuestion q : questions) { | ||
System.out.println(q); | ||
} | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion[] makeQuestions() { | ||
MultipleChoiceQuizQuestion[] questions = new MultipleChoiceQuizQuestion[11]; | ||
questions[0] = makeQuestion0(); | ||
questions[1] = makeQuestion1(); | ||
questions[2] = makeQuestion2(); | ||
questions[3] = makeQuestion3(); | ||
questions[4] = makeQuestion4(); | ||
questions[5] = makeQuestion5(); | ||
questions[6] = makeQuestion6(); | ||
questions[7] = makeQuestion7(); | ||
questions[8] = makeQuestion8(); | ||
questions[9] = makeQuestion9(); | ||
questions[10] = makeQuestion10(); | ||
|
||
return questions; | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion0() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "To make backups of files"); | ||
answerChoices.put(AnswerChoice.B, "To keep a record of changes over time"); | ||
answerChoices.put(AnswerChoice.C, " To delete unnecessary files"); | ||
answerChoices.put(AnswerChoice.D, "To run code more efficiently"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
0, "What is the main purpose of version control?", answerChoices, AnswerChoice.B); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion1() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "A duplicate copy of a repository that you own and modify"); | ||
answerChoices.put(AnswerChoice.B, "A temporary backup of the code"); | ||
answerChoices.put(AnswerChoice.C, "A tool for merging branches"); | ||
answerChoices.put(AnswerChoice.D, "What is a fork in Git?"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
1, "What is a fork in Git?", answerChoices, AnswerChoice.A); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion2() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "Pull the latest changes"); | ||
answerChoices.put(AnswerChoice.B, "Commit changes locally"); | ||
answerChoices.put(AnswerChoice.C, "Push changes to the server"); | ||
answerChoices.put(AnswerChoice.D, "Write code directly in GitHub"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
2, "Which of the following is NOT part of the basic Git workflow?", answerChoices, AnswerChoice.D); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion3() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "git commit"); | ||
answerChoices.put(AnswerChoice.B, "git merge"); | ||
answerChoices.put(AnswerChoice.C, "git branch"); | ||
answerChoices.put(AnswerChoice.D, "git pull"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
3, "What command is used to combine changes from different branches?", answerChoices, AnswerChoice.B); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion4() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "Eclipse"); | ||
answerChoices.put(AnswerChoice.B, "IntelliJ IDEA"); | ||
answerChoices.put(AnswerChoice.C, "NetBeans"); | ||
answerChoices.put(AnswerChoice.D, "VS Code"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
4, "Which IDE is being used in the class?", answerChoices, AnswerChoice.D); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion5() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "Extensions"); | ||
answerChoices.put(AnswerChoice.B, "Debugger"); | ||
answerChoices.put(AnswerChoice.C, "Dev Containers"); | ||
answerChoices.put(AnswerChoice.D, "Source Control"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
5, "What feature allows developers to work from the same pre-configured environment in VS Code?", answerChoices, AnswerChoice.C); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion6() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "Editing and refactoring code"); | ||
answerChoices.put(AnswerChoice.B, "Browsing code"); | ||
answerChoices.put(AnswerChoice.C, "Playing music"); | ||
answerChoices.put(AnswerChoice.D, "Managing source control"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
6, "What is NOT a reason for using an IDE?", answerChoices, AnswerChoice.C); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion7() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "pwd"); | ||
answerChoices.put(AnswerChoice.B, "ls"); | ||
answerChoices.put(AnswerChoice.C, "cd"); | ||
answerChoices.put(AnswerChoice.D, "mkdir"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
7, "Which command is used to print the current working directory in the terminal?", answerChoices, AnswerChoice.A); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion8() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "pwd"); | ||
answerChoices.put(AnswerChoice.B, "ls"); | ||
answerChoices.put(AnswerChoice.C, "cd"); | ||
answerChoices.put(AnswerChoice.D, "mkdir"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
8, "Which command is used to change directories in the terminal?", answerChoices, AnswerChoice.C); | ||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion9() { | ||
|
||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "Change file or directory permissions"); | ||
answerChoices.put(AnswerChoice.B, "List files in a directory"); | ||
answerChoices.put(AnswerChoice.C, "Remove a file or directory"); | ||
answerChoices.put(AnswerChoice.D, "Copy a file or directory"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
9, "What does the command `chmod` do?", answerChoices, AnswerChoice.A); | ||
|
||
} | ||
|
||
public static MultipleChoiceQuizQuestion makeQuestion10() { | ||
Map<AnswerChoice, String> answerChoices = new HashMap<>(); | ||
answerChoices.put(AnswerChoice.A, "⌘ + Shift + T"); | ||
answerChoices.put(AnswerChoice.B, "⌘ + Spacebar, then type terminal"); | ||
answerChoices.put(AnswerChoice.C, "⌘ + Q"); | ||
answerChoices.put(AnswerChoice.D, "⌘ + S, then type terminal"); | ||
|
||
return new MultipleChoiceQuizQuestion( | ||
10, "What is the shortcut for getting to the Mac terminal?", answerChoices, AnswerChoice.B); | ||
|
||
} | ||
|
||
} |
Empty file.
14 changes: 14 additions & 0 deletions
14
lesson_02/quiz-java/app/src/test/java/org/example/AppTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* This source file was generated by the Gradle 'init' task | ||
*/ | ||
package org.example; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class LessonTest { | ||
@Test void lessonHasQuestions() { | ||
assertNotNull(Lesson.makeQuestions(), "lesson should have questions"); | ||
assertTrue(Lesson.makeQuestions().length > 0, "lesson should have at least one question"); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
lesson_02/quiz-java/app/src/test/java/org/example/LessonTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* This source file was generated by the Gradle 'init' task | ||
*/ | ||
package org.example; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class LessonTest { | ||
@Test void lessonHasQuestions() { | ||
assertNotNull(Lesson.makeQuestions(), "lesson should have questions"); | ||
assertTrue(Lesson.makeQuestions().length > 0, "lesson should have at least one question"); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# This file was generated by the Gradle 'init' task. | ||
# https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties | ||
|
||
org.gradle.configuration-cache=true | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[versions] | ||
guava = "33.4.6-jre" | ||
junit-jupiter = "5.12.1" | ||
|
||
[libraries] | ||
guava = { module = "com.google.guava:guava", version.ref = "guava" } | ||
junit_jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter" } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made this change temporarily since the imports in the Java code kept getting removed. You should be able to remove this patch eventually.