diff --git a/learning-java-project/java/javatest/.vscode/settings.json b/learning-java-project/java/javatest/.vscode/settings.json new file mode 100644 index 00000000..96ee3d15 --- /dev/null +++ b/learning-java-project/java/javatest/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin" +} diff --git a/learning-java-project/java/javatest/README.md b/learning-java-project/java/javatest/README.md new file mode 100644 index 00000000..7c03a532 --- /dev/null +++ b/learning-java-project/java/javatest/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/learning-java-project/java/javatest/bin/App.class b/learning-java-project/java/javatest/bin/App.class new file mode 100644 index 00000000..34799af2 Binary files /dev/null and b/learning-java-project/java/javatest/bin/App.class differ diff --git a/learning-java-project/java/javatest/src/App.class b/learning-java-project/java/javatest/src/App.class new file mode 100644 index 00000000..5b429aad Binary files /dev/null and b/learning-java-project/java/javatest/src/App.class differ diff --git a/learning-java-project/java/javatest/src/App.java b/learning-java-project/java/javatest/src/App.java new file mode 100644 index 00000000..0a839f9b --- /dev/null +++ b/learning-java-project/java/javatest/src/App.java @@ -0,0 +1,5 @@ +public class App { + public static void main(String[] args) throws Exception { + System.out.println("Hello, World!"); + } +} diff --git a/src/Main.class b/src/Main.class new file mode 100644 index 00000000..48407ae4 Binary files /dev/null and b/src/Main.class differ diff --git a/src/Main.java b/src/Main.java index 4b88cab2..88ff3643 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,26 +1,41 @@ +import java.util.Scanner; public class Main { public static void main(String args[]) { - String question = ""; - String choiceOne = ""; - String choiceTwo = ""; - String choiceThree = ""; - - String correctAnswer = choiceTwo; - + String question = "Say my name!"; + String choiceOne = "Willie Wonka"; + String choiceTwo = "Woodrow Wilson"; + String choiceThree = "Walter White"; + + String correctAnswer = choiceThree; + // Write a print statement asking the question + System.out.println(question); // Write a print statement giving the answer choices - + System.out.println(choiceOne); + System.out.println(choiceTwo); + System.out.println(choiceThree); + + Scanner input = new Scanner(System.in); // Have the user input an answer // Retrieve the user's input - + String userAnswer = input.next(); + input.close(); + // If the user's input matches the correctAnswer... // then the user is correct and we want to print out a congrats message to the user. - + + if(userAnswer.equals(correctAnswer)) { + System.out.println("Congrats! You have choosen the correct answer!!!"); + }; + // If the user's input does not match the correctAnswer... // then the user is incorrect and we want to print out a message saying that the user is incorrect as well as what the correct choice was. - + + if(!userAnswer.equals(correctAnswer)) { + System.out.println("You failed!!!"); + } } }