Skip to content

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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"source.fixAll.eslint": "explicit",
"source.organizeImports": "explicit"
},
"[java]": {
Copy link
Contributor

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.

"editor.codeActionsOnSave": {
"source.organizeImports": "never"
}
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand Down
6 changes: 6 additions & 0 deletions lesson_02/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions lesson_02/quiz-java/.gitattributes
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

5 changes: 5 additions & 0 deletions lesson_02/quiz-java/.gitignore
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
33 changes: 33 additions & 0 deletions lesson_02/quiz-java/app/build.gradle
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 lesson_02/quiz-java/app/src/main/java/org/example/Lesson.java
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 lesson_02/quiz-java/app/src/test/java/org/example/AppTest.java
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 lesson_02/quiz-java/app/src/test/java/org/example/LessonTest.java
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");
}
}
5 changes: 5 additions & 0 deletions lesson_02/quiz-java/gradle.properties
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

7 changes: 7 additions & 0 deletions lesson_02/quiz-java/gradle/libs.versions.toml
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.
7 changes: 7 additions & 0 deletions lesson_02/quiz-java/gradle/wrapper/gradle-wrapper.properties
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
Loading