Skip to content

feat/lesson_02/benjaminscott/typescripttest #80

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
wants to merge 5 commits into from
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
22 changes: 11 additions & 11 deletions lesson_02/quiz/src/lesson2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class Lesson2 {
[AnswerChoice.C, "To delete unnecessary files"],
[AnswerChoice.D, "To run code more efficiently"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.B, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -56,7 +56,7 @@ export class Lesson2 {
[AnswerChoice.C, "A tool for merging branches"],
[AnswerChoice.D, "A way to delete a repository"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.A, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -70,7 +70,7 @@ export class Lesson2 {
[AnswerChoice.C, "Push changes to the server"],
[AnswerChoice.D, "Write code directly in GitHub"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.D, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -84,7 +84,7 @@ export class Lesson2 {
[AnswerChoice.C, "git branch"],
[AnswerChoice.D, "git pull"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.B, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -98,7 +98,7 @@ export class Lesson2 {
[AnswerChoice.C, "NetBeans"],
[AnswerChoice.D, "VS Code"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.D, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -112,7 +112,7 @@ export class Lesson2 {
[AnswerChoice.C, "Dev Containers"],
[AnswerChoice.D, "Source Control"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.C, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -126,7 +126,7 @@ export class Lesson2 {
[AnswerChoice.C, "Playing music"],
[AnswerChoice.D, "Managing source control"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.C, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -140,7 +140,7 @@ export class Lesson2 {
[AnswerChoice.C, "cd"],
[AnswerChoice.D, "mkdir"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.B, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -154,7 +154,7 @@ export class Lesson2 {
[AnswerChoice.C, "cd"],
[AnswerChoice.D, "mkdir"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.C, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -168,7 +168,7 @@ export class Lesson2 {
[AnswerChoice.C, "Remove a file or directory"],
[AnswerChoice.D, "Copy a file or directory"],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.A, // Replace `UNANSWERED` with the correct answer.
);
}

Expand All @@ -182,7 +182,7 @@ export class Lesson2 {
[AnswerChoice.C, "⌘ + Q"],
[AnswerChoice.D, '⌘ + S, then type "terminal"'],
]),
AnswerChoice.UNANSWERED, // Replace `UNANSWERED` with the correct answer.
AnswerChoice.B, // Replace `UNANSWERED` with the correct answer.
);
}
}
Expand Down
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
37 changes: 37 additions & 0 deletions lesson_02/quiz_java/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
plugins {
java
id("org.springframework.boot") version "3.1.0"
id("io.spring.dependency-management") version "1.1.0"
application
}


java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(21))
}
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.apache.commons:commons-text:1.10.0")
implementation(project(":instructional-lib"))
implementation("org.springframework.boot:spring-boot-starter")
testImplementation("org.springframework.boot:spring-boot-starter-test")

}



application {
// Define the main class for the application.
mainClass.set("org.example.Lesson2")
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
190 changes: 190 additions & 0 deletions lesson_02/quiz_java/app/src/main/java/org/example/Lesson2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
package org.example;

import java.util.HashMap;
import java.util.Map;

import com.codedifferently.instructional.quiz.AnswerChoice;
import com.codedifferently.instructional.quiz.MultipleChoiceQuizQuestion;
import com.codedifferently.instructional.quiz.QuizPrinter;
import com.codedifferently.instructional.quiz.QuizQuestion;
/**
* Lesson 2: Quiz on Git, IDEs, and Terminal Commands.
*/
public class Lesson2 {
public static void main(String[] args) {
QuizQuestion[] quizQuestions = makeQuizQuestions();
if (!quizQuestions == null) throw new RuntimeException("Quiz questions cannot be null");
QuizPrinter printer = new QuizPrinter();
printer.printQuiz(quizQuestions);
}

public static QuizQuestion[] makeQuizQuestions() {
return new QuizQuestion[] {
makeQuestion0(),
makeQuestion1(),
makeQuestion2(),
makeQuestion3(),
makeQuestion4(),
makeQuestion5(),
makeQuestion6(),
makeQuestion7(),
makeQuestion8(),
makeQuestion9(),
makeQuestion10()
};
}

private static makeQuestion0() {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "To make backups of files");
choices.put(AnswerChoice.B, "To keep a record of changes over time");
choices.put(AnswerChoice.C, "To delete unnecessary files");
choices.put(AnswerChoice.D, "To run code more efficiently");
return new MultipleChoiceQuizQuestion(
0,
"What is the main purpose of version control?",
choices,
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion1(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "A duplicate copy of a repository that you own and modify");
choices.put(AnswerChoice.B, "A temporary backup of the code");
choices.put(AnswerChoice.C, "A tool for merging branches");
choices.put(AnswerChoice.D, "A way to delete a repository");
return new MultipleChoiceQuizQuestion(
1,
"What is a fork in Git?",
choices,
AnswerChoice.A // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion2(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "Pull the latest changes");
choices.put(AnswerChoice.B, "Commit changes locally");
choices.put(AnswerChoice.C, "Push changes to the server");
choices.put(AnswerChoice.D, "Write code directly in GitHub");
return new MultipleChoiceQuizQuestion(
2,
"Which of the following is NOT part of the basic Git workflow?",
choices,
AnswerChoice.D // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion3(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "git commit");
choices.put(AnswerChoice.B, "git merge");
choices.put(AnswerChoice.C, "git branch");
choices.put(AnswerChoice.D, "git pull");
return new MultipleChoiceQuizQuestion(
3,
"What command is used to combine changes from different branches?",
choices,
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion4(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "Eclipse");
choices.put(AnswerChoice.B, "IntelliJ IDEA");
choices.put(AnswerChoice.C, "NetBeans");
choices.put(AnswerChoice.D, "VS Code");
return new MultipleChoiceQuizQuestion(
4,
"Which IDE is being used in the class?",
choices,
AnswerChoice.D // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion5(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "Extensions");
choices.put(AnswerChoice.B, "Debugger");
choices.put(AnswerChoice.C, "Dev Containers");
choices.put(AnswerChoice.D, "Source Control");
return new MultipleChoiceQuizQuestion(
5,
"What feature allows developers to work from the same pre-configured environment in VS Code?",
choices,
AnswerChoice.C // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion6(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "Editing and refactoring code");
choices.put(AnswerChoice.B, "Browsing code");
choices.put(AnswerChoice.C, "Playing music");
choices.put(AnswerChoice.D, "Managing source control");
return new MultipleChoiceQuizQuestion(
6,
"What is NOT a reason for using an IDE?",
choices,
AnswerChoice.C // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion7(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "pwd");
choices.put(AnswerChoice.B, "ls");
choices.put(AnswerChoice.C, "cd");
choices.put(AnswerChoice.D, "mkdir");
return new MultipleChoiceQuizQuestion(
7,
"What is the command to list files in the current directory?",
choices,
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion8(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "pwd");
choices.put(AnswerChoice.B, "ls");
choices.put(AnswerChoice.C, "cd");
choices.put(AnswerChoice.D, "mkdir");
return new MultipleChoiceQuizQuestion(
8,
"Which command is used to change directories in the terminal?",
choices,
AnswerChoice.C // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion9(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "Change file or directory permissions");
choices.put(AnswerChoice.B, "List files in a directory");
choices.put(AnswerChoice.C, "Remove a file or directory");
choices.put(AnswerChoice.D, "Copy a file or directory");
return new MultipleChoiceQuizQuestion(
9,
"What does the command `chmod` do?",
choices,
AnswerChoice.A // Replace `UNANSWERED` with the correct answer.
);
}

private static makeQuestion10(): QuizQuestion {
Map<AnswerChoice, String> choices = new HashMap<>();
choices.put(AnswerChoice.A, "⌘ + Shift + T");
choices.put(AnswerChoice.B, '⌘ + Spacebar, then type "terminal"');
choices.put(AnswerChoice.C, "⌘ + Q");
choices.put(AnswerChoice.D, '⌘ + S, then type "terminal"');
return new MultipleChoiceQuizQuestion(
10,
"What is the shortcut for getting to the Mac terminal?",
choices,
AnswerChoice.B // Replace `UNANSWERED` with the correct answer.
);
}
}
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 AppTest {
@Test void appHasAGreeting() {
App classUnderTest = new App();
assertNotNull(classUnderTest.getGreeting(), "app should have a greeting");
}
}
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

10 changes: 10 additions & 0 deletions lesson_02/quiz_java/gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file was generated by the Gradle 'init' task.
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[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-8.7-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading
Loading