-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6febfde
Showing
11 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,3 @@ | ||
.gradle | ||
.idea | ||
gradlew |
This file contains 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,21 @@ | ||
plugins { | ||
id 'java' | ||
} | ||
|
||
group 'org.example' | ||
version '1.0-SNAPSHOT' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
// testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1' | ||
// testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1' | ||
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1' | ||
|
||
} | ||
|
||
test { | ||
useJUnitPlatform() | ||
} |
Binary file added
BIN
+4.08 KB
build/classes/java/main/JSON_File_Manipulation/QuizProgramUsingJSON.class
Binary file not shown.
This file contains 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 @@ | ||
[ | ||
{ | ||
"Option d:": "Testing closure", | ||
"Option c:": "Deployment phase", | ||
"Option b:": "Requirement Phase", | ||
"Option a:": "Testing Phase", | ||
"answer": "d", | ||
"Question": "Which of the following is not a valid phase of SDLC (Software Development Life Cycle)?" | ||
}, | ||
{ | ||
"Option d:": "None of the above", | ||
"Option c:": "Design based testing", | ||
"Option b:": "Error guessing technique", | ||
"Option a:": "Structural testing", | ||
"answer": "a", | ||
"Question": "Which of the following testing is also known as white-box testing?" | ||
}, | ||
{ | ||
"Option d:": "None of the above", | ||
"Option c:": "Black box testing", | ||
"Option b:": "White-box testing", | ||
"Option a:": "White box and black box testing", | ||
"answer": "c", | ||
"Question": "Which of the following testing is related to the boundary value analysis?" | ||
}, | ||
{ | ||
"Option d:": "Test type", | ||
"Option c:": "SDLC Model", | ||
"Option b:": "Test level", | ||
"Option a:": "Test design technique", | ||
"answer": "d", | ||
"Question": " Functional testing is a ------?" | ||
}, | ||
{ | ||
"Option d:": "All of the above", | ||
"Option c:": "System testing", | ||
"Option b:": "Unit testing", | ||
"Option a:": "Integration testing", | ||
"answer": "d", | ||
"Question": "What are the different levels of Testing?" | ||
}, | ||
{ | ||
"Option d:": "Testing closure", | ||
"Option c:": "Test Design", | ||
"Option b:": "Requirement Gathering", | ||
"Option a:": "Testing Planning", | ||
"answer": "b", | ||
"Question": "Which of the following is not a part of STLC (Software Testing Life Cycle)?" | ||
}, | ||
{ | ||
"Option d:": "Test design technique", | ||
"Option c:": "Test Level", | ||
"Option b:": "Test Execution Level", | ||
"Option a:": "Test type", | ||
"answer": "b", | ||
"Question": "Sanity testing is a ------?" | ||
}, | ||
{ | ||
"Option d:": "None of the above", | ||
"Option c:": "User'sand developer's end", | ||
"Option b:": "Developer's end", | ||
"Option a:": "User's end", | ||
"answer": "b", | ||
"Question": "In which environment we can performed the Alpha testing?" | ||
}, | ||
{ | ||
"Option d:": "Entry and exit criteria", | ||
"Option c:": "Incident reports", | ||
"Option b:": "Risk", | ||
"Option a:": "Schedule", | ||
"answer": "c", | ||
"Question": "Which of the below is not a part of the Test Plan?" | ||
}, | ||
{ | ||
"Option d:": "None of the mentioned", | ||
"Option c:": "Procedure Errors", | ||
"Option b:": "Interface Errors", | ||
"Option a:": "Design Errors", | ||
"answer": "b", | ||
"Question": "What is the key objective of Integration testing?" | ||
}, | ||
{ | ||
"Option d:": "Grey Box Test Design Technique", | ||
"Option c:": "Black Box Test Design Technique", | ||
"Option b:": "White Box Test Design Technique", | ||
"Option a:": "Experience-based Test Design Technique", | ||
"answer": "a", | ||
"Question": "Exploratory testing is a -----?" | ||
}, | ||
{ | ||
"Option d:": "Both option a & c", | ||
"Option c:": "When the environment has been modified", | ||
"Option b:": "As frequently as possible", | ||
"Option a:": "After the software has been modified", | ||
"answer": "d", | ||
"Question": "What is the best time to perform Regression testing?" | ||
}, | ||
{ | ||
"Option d:": "All of the above", | ||
"Option c:": "The testing team is not good", | ||
"Option b:": "Developers are super", | ||
"Option a:": "Product is old", | ||
"answer": "c", | ||
"Question": "Does the customer get a 100% bug-free product?" | ||
}, | ||
{ | ||
"Option d:": "All of the above", | ||
"Option c:": "Grey box testing", | ||
"Option b:": "Black box testing", | ||
"Option a:": "White-box testing", | ||
"answer": "a", | ||
"Question": " Cyclomatic complexity is?" | ||
}, | ||
{ | ||
"Option d:": "Database testing", | ||
"Option c:": "Statement testing", | ||
"Option b:": "System testing", | ||
"Option a:": "Function testing", | ||
"answer": "c", | ||
"Question": "Which of the following is not part of the Test type?" | ||
}, | ||
{ | ||
"Option d:": "Test Plan", | ||
"Option c:": "Test Case", | ||
"Option b:": "Test Summary Report", | ||
"Option a:": "Defect Report", | ||
"answer": "d", | ||
"Question": "Which Test Document is used to define the Exit Criteria of Testing?" | ||
}, | ||
{ | ||
"Option d:": "How many more test cases need to write?", | ||
"Option c:": "Different Tools to perform Regression Testing", | ||
"Option b:": "How much regression testing should be done?", | ||
"Option a:": "Exit Criteria", | ||
"answer": "b", | ||
"Question": "Impact analysis helps us to decide which of the following testing?" | ||
}, | ||
{ | ||
"Option d:": "Combination of all", | ||
"Option c:": "Black Box testing", | ||
"Option b:": "Grey box testing", | ||
"Option a:": "White-box testing", | ||
"answer": "c", | ||
"Question": "Which testing technique is used for usability testing?" | ||
}, | ||
{ | ||
"Option d:": "Bottom-up approach", | ||
"Option c:": "Functional incrimination", | ||
"Option b:": "Top-down approach", | ||
"Option a:": "Big bang approach", | ||
"answer": "a", | ||
"Question": "Which is not the right approach of Incremental testing approach?" | ||
}, | ||
{ | ||
"Option d:": "None of the above", | ||
"Option c:": "User's end", | ||
"Option b:": "Developer's end", | ||
"Option a:": "User's and developer's end", | ||
"answer": "c", | ||
"Question": "In which environment we can performed the Beta testing?" | ||
} | ||
] |
Binary file not shown.
Binary file not shown.
This file contains 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 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
This file contains 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,89 @@ | ||
@rem | ||
@rem Copyright 2015 the original author or authors. | ||
@rem | ||
@rem Licensed under the Apache License, Version 2.0 (the "License"); | ||
@rem you may not use this file except in compliance with the License. | ||
@rem You may obtain a copy of the License at | ||
@rem | ||
@rem https://www.apache.org/licenses/LICENSE-2.0 | ||
@rem | ||
@rem Unless required by applicable law or agreed to in writing, software | ||
@rem distributed under the License is distributed on an "AS IS" BASIS, | ||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
@rem See the License for the specific language governing permissions and | ||
@rem limitations under the License. | ||
@rem | ||
|
||
@if "%DEBUG%" == "" @echo off | ||
@rem ########################################################################## | ||
@rem | ||
@rem Gradle startup script for Windows | ||
@rem | ||
@rem ########################################################################## | ||
|
||
@rem Set local scope for the variables with windows NT shell | ||
if "%OS%"=="Windows_NT" setlocal | ||
|
||
set DIRNAME=%~dp0 | ||
if "%DIRNAME%" == "" set DIRNAME=. | ||
set APP_BASE_NAME=%~n0 | ||
set APP_HOME=%DIRNAME% | ||
|
||
@rem Resolve any "." and ".." in APP_HOME to make it shorter. | ||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi | ||
|
||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. | ||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" | ||
|
||
@rem Find java.exe | ||
if defined JAVA_HOME goto findJavaFromJavaHome | ||
|
||
set JAVA_EXE=java.exe | ||
%JAVA_EXE% -version >NUL 2>&1 | ||
if "%ERRORLEVEL%" == "0" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:findJavaFromJavaHome | ||
set JAVA_HOME=%JAVA_HOME:"=% | ||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe | ||
|
||
if exist "%JAVA_EXE%" goto execute | ||
|
||
echo. | ||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% | ||
echo. | ||
echo Please set the JAVA_HOME variable in your environment to match the | ||
echo location of your Java installation. | ||
|
||
goto fail | ||
|
||
:execute | ||
@rem Setup the command line | ||
|
||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar | ||
|
||
|
||
@rem Execute Gradle | ||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* | ||
|
||
:end | ||
@rem End local scope for the variables with windows NT shell | ||
if "%ERRORLEVEL%"=="0" goto mainEnd | ||
|
||
:fail | ||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of | ||
rem the _cmd.exe /c_ return code! | ||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 | ||
exit /b 1 | ||
|
||
:mainEnd | ||
if "%OS%"=="Windows_NT" endlocal | ||
|
||
:omega |
This file contains 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,2 @@ | ||
rootProject.name = 'JavaSimpleQuizJSON' | ||
|
101 changes: 101 additions & 0 deletions
101
src/main/java/JSON_File_Manipulation/QuizProgramUsingJSON.java
This file contains 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,101 @@ | ||
|
||
package JSON_File_Manipulation; | ||
|
||
import org.json.simple.parser.JSONParser; | ||
import org.json.simple.JSONArray; | ||
import org.json.simple.JSONObject; | ||
import org.json.simple.parser.ParseException; | ||
//import org.json.simple.parser.*; | ||
|
||
|
||
import java.io.FileNotFoundException; | ||
import java.io.FileReader; | ||
import java.io.FileWriter; | ||
import java.io.IOException; | ||
import java.util.Random; | ||
import java.util.Scanner; | ||
|
||
public class QuizProgramUsingJSON { | ||
public static void main(String[] args) throws IOException, ParseException { | ||
System.out.println("Select One of the two options from below:\n" + | ||
"1. Add Quiz\n" + | ||
"2. Start Quiz"); | ||
Scanner sc=new Scanner(System.in); | ||
int option=sc.nextInt(); | ||
if(option==1){ | ||
addingQuestion(); | ||
} | ||
else{ | ||
startQuiz(); | ||
} | ||
} | ||
public static void addingQuestion() throws IOException, ParseException { | ||
char ch = 'y'; | ||
String filename = "./src/main/resources/QuizBank.json"; | ||
Scanner sc=new Scanner(System.in); | ||
do { | ||
// JSONArray jsonArray=new JSONArray(); | ||
JSONParser jsonParser = new JSONParser(); | ||
Object obj = jsonParser.parse(new FileReader(filename)); | ||
JSONObject jsonObject = new JSONObject(); | ||
System.out.println("Please add a question here:"); | ||
String question = sc.nextLine(); | ||
jsonObject.put("Question", question); | ||
System.out.println("Input Options:"); | ||
for (int i = 97; i < 101; i++) { | ||
String questionOption = "Option " + (char) (i) + ":"; | ||
System.out.println(questionOption); | ||
String inputQuestionOption = sc.nextLine(); | ||
jsonObject.put(questionOption, inputQuestionOption); | ||
} | ||
System.out.println("Please input the correct answer: "); | ||
String answer = sc.nextLine(); | ||
jsonObject.put("answer", answer); | ||
JSONArray jsonArray = (JSONArray) obj; | ||
jsonArray.add(jsonObject); | ||
FileWriter file = new FileWriter(filename); | ||
file.write(jsonArray.toJSONString()); | ||
file.flush(); | ||
file.close(); | ||
System.out.println("Quiz saved at the database. Do you want to add more? (y/n)"); | ||
ch = sc.nextLine().charAt(0); | ||
} | ||
while (ch != 'n'); | ||
sc.close(); | ||
} | ||
public static void startQuiz() throws IOException, ParseException { | ||
System.out.println("You will be asked 5 questions, each questions has 1 marks"); | ||
int correct=0; | ||
Scanner sc=new Scanner(System.in); | ||
Random random = new Random(); | ||
|
||
for(int i=1;i<=5;i++){ | ||
int pos= random.nextInt(20); | ||
// int pos=0; | ||
System.out.println("Question "+i+":"); | ||
String filename="./src/main/resources/QuizBank.json"; | ||
JSONParser jsonParser=new JSONParser(); | ||
Object obj= jsonParser.parse(new FileReader(filename)); | ||
JSONArray jsonArray=(JSONArray) obj; | ||
// System.out.println(jsonArray); | ||
JSONObject jsonObject=(JSONObject) jsonArray.get(pos); | ||
System.out.println((String)jsonObject.get("Question")); | ||
for (int j = 97; j < 101; j++) { | ||
String questionOption = "Option " + (char) (j) + ":"; | ||
System.out.println(questionOption+(String)jsonObject.get(questionOption)); | ||
} | ||
System.out.println("Input your answer"); | ||
String answer=sc.nextLine(); | ||
String actualAnswer= (String)jsonObject.get("answer"); | ||
// char actualAnswer=actualAnswerString.charAt(0); | ||
|
||
if(answer.equals(actualAnswer)){ | ||
System.out.println("Correct!"); | ||
correct+=1; | ||
} | ||
else | ||
System.out.println("Not correct"); | ||
} | ||
System.out.printf("Result:You got: %d out of 5",correct); | ||
} | ||
} |
This file contains 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 @@ | ||
[{"Option d:":"Testing closure","Option c:":"Deployment phase","Option b:":"Requirement Phase","Option a:":"Testing Phase","answer":"d","Question":"Which of the following is not a valid phase of SDLC (Software Development Life Cycle)?"},{"Option d:":"None of the above","Option c:":"Design based testing","Option b:":"Error guessing technique","Option a:":"Structural testing","answer":"a","Question":"Which of the following testing is also known as white-box testing?"},{"Option d:":"None of the above","Option c:":"Black box testing","Option b:":"White-box testing","Option a:":"White box and black box testing","answer":"c","Question":"Which of the following testing is related to the boundary value analysis?"},{"Option d:":"Test type","Option c:":"SDLC Model","Option b:":"Test level","Option a:":"Test design technique","answer":"d","Question":" Functional testing is a ------?"},{"Option d:":"All of the above","Option c:":"System testing","Option b:":"Unit testing","Option a:":"Integration testing","answer":"d","Question":"What are the different levels of Testing?"},{"Option d:":"Testing closure","Option c:":"Test Design","Option b:":"Requirement Gathering","Option a:":"Testing Planning","answer":"b","Question":"Which of the following is not a part of STLC (Software Testing Life Cycle)?"},{"Option d:":"Test design technique","Option c:":"Test Level","Option b:":"Test Execution Level","Option a:":"Test type","answer":"b","Question":"Sanity testing is a ------?"},{"Option d:":"None of the above","Option c:":"User'sand developer's end","Option b:":"Developer's end","Option a:":"User's end","answer":"b","Question":"In which environment we can performed the Alpha testing?"},{"Option d:":"Entry and exit criteria","Option c:":"Incident reports","Option b:":"Risk","Option a:":"Schedule","answer":"c","Question":"Which of the below is not a part of the Test Plan?"},{"Option d:":"None of the mentioned","Option c:":"Procedure Errors","Option b:":"Interface Errors","Option a:":"Design Errors","answer":"b","Question":"What is the key objective of Integration testing?"},{"Option d:":"Grey Box Test Design Technique","Option c:":"Black Box Test Design Technique","Option b:":"White Box Test Design Technique","Option a:":"Experience-based Test Design Technique","answer":"a","Question":"Exploratory testing is a -----?"},{"Option d:":"Both option a & c","Option c:":"When the environment has been modified","Option b:":"As frequently as possible","Option a:":"After the software has been modified","answer":"d","Question":"What is the best time to perform Regression testing?"},{"Option d:":"All of the above","Option c:":"The testing team is not good","Option b:":"Developers are super","Option a:":"Product is old","answer":"c","Question":"Does the customer get a 100% bug-free product?"},{"Option d:":"All of the above","Option c:":"Grey box testing","Option b:":"Black box testing","Option a:":"White-box testing","answer":"a","Question":" Cyclomatic complexity is?"},{"Option d:":"Database testing","Option c:":"Statement testing","Option b:":"System testing","Option a:":"Function testing","answer":"c","Question":"Which of the following is not part of the Test type?"},{"Option d:":"Test Plan","Option c:":"Test Case","Option b:":"Test Summary Report","Option a:":"Defect Report","answer":"d","Question":"Which Test Document is used to define the Exit Criteria of Testing?"},{"Option d:":"How many more test cases need to write?","Option c:":"Different Tools to perform Regression Testing","Option b:":"How much regression testing should be done?","Option a:":"Exit Criteria","answer":"b","Question":"Impact analysis helps us to decide which of the following testing?"},{"Option d:":"Combination of all","Option c:":"Black Box testing","Option b:":"Grey box testing","Option a:":"White-box testing","answer":"c","Question":"Which testing technique is used for usability testing?"},{"Option d:":"Bottom-up approach","Option c:":"Functional incrimination","Option b:":"Top-down approach","Option a:":"Big bang approach","answer":"a","Question":"Which is not the right approach of Incremental testing approach?"},{"Option d:":"None of the above","Option c:":"User's end","Option b:":"Developer's end","Option a:":"User's and developer's end","answer":"c","Question":"In which environment we can performed the Beta testing?"},{"Option d:":"Test case design\/ data management techniques","Option c:":"Test execution techniques","Option b:":"Test verification techniques","Option a:":"Test control management techniques","answer":"d","Question":" What is error guessing in software testing?"},{"Option d:":"After the installation phase","Option c:":"After SRS creation","Option b:":"After designing phase","Option a:":"After the coding phase","answer":"a","Question":" After which phase, we can proceed to the white box testing?"}] |