Skip to content
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
9 changes: 9 additions & 0 deletions lesson_02/quiz_java/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# 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

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
70 changes: 70 additions & 0 deletions lesson_02/quiz_java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Lesson 02 Quiz - Java Port

This is a Java port of the Lesson 02 quiz application, originally written in TypeScript. It demonstrates the same quiz functionality using the `codedifferently-instructional` Java library.

## Features

- 11 multiple choice questions covering:
- Version control and Git concepts
- IDE and development environment topics
- Terminal/command line basics
- Mac-specific shortcuts

## Prerequisites

- Java 21 or later
- Gradle (included via wrapper)

## Building and Running

### Build the project
```bash
./gradlew build
```

### Run the quiz
```bash
./gradlew run
```

### Run tests
```bash
./gradlew test
```

## Project Structure

- `app/src/main/java/quiz_java/Lesson2.java` - Main quiz implementation
- `app/src/main/java/quiz_java/App.java` - Application entry point
- `app/src/test/java/quiz_java/Lesson2Test.java` - Unit tests
- `app/build.gradle.kts` - Build configuration
- `settings.gradle.kts` - Multi-project settings

## Dependencies

This project uses the `codedifferently-instructional` library located at `../../lib/java/codedifferently-instructional/instructional-lib` which provides:

- `AnswerChoice` enum for multiple choice options
- `MultipleChoiceQuizQuestion` class for question representation
- `QuizPrinter` class for displaying the quiz
- `QuizQuestion` base class

## Quiz Questions

The Java implementation contains the same 11 questions as the TypeScript version:

1. **Question 0**: Version control purpose → Answer: B (To keep a record of changes over time)
2. **Question 1**: Git fork definition → Answer: A (A duplicate copy of a repository that you own and modify)
3. **Question 2**: Non-Git workflow activity → Answer: D (Write code directly in GitHub)
4. **Question 3**: Branch merging command → Answer: B (git merge)
5. **Question 4**: Class IDE → Answer: D (VS Code)
6. **Question 5**: VS Code environment feature → Answer: C (Dev Containers)
7. **Question 6**: Non-IDE purpose → Answer: C (Playing music)
8. **Question 7**: Directory listing command → Answer: B (ls)
9. **Question 8**: Directory change command → Answer: C (cd)
10. **Question 9**: chmod command purpose → Answer: A (Change file or directory permissions)
11. **Question 10**: Mac terminal shortcut → Answer: B (⌘ + Spacebar, then type "terminal")

## Notes

This Java port maintains the same structure and answers as the original TypeScript quiz while leveraging the Java ecosystem and demonstrating cross-language compatibility.
46 changes: 46 additions & 0 deletions lesson_02/quiz_java/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details on building Java & JVM projects, please refer to https://docs.gradle.org/8.8/userguide/building_java_projects.html in the Gradle documentation.
*/

plugins {
// Apply the application plugin to add support for building a CLI application in Java.
application
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}

dependencies {
// Use JUnit Jupiter for testing.
testImplementation(libs.junit.jupiter)

testRuntimeOnly("org.junit.platform:junit-platform-launcher")

// This dependency is used by the application.
implementation(libs.guava)

// Add the codedifferently-instructional library
implementation(project(":instructional-lib"))
}

// 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 = "quiz_java.App"
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
15 changes: 15 additions & 0 deletions lesson_02/quiz_java/app/src/main/java/quiz_java/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This source file was generated by the Gradle 'init' task
*/
package quiz_java;

public class App {
public String getGreeting() {
return "Hello World!";
}

public static void main(String[] args) {
// Run the Lesson2 quiz
new Lesson2().run();
}
}
Loading