Skip to content
Snippets Groups Projects
Commit edfdd7c2 authored by Furkan Workstation's avatar Furkan Workstation
Browse files

All file updated

parent b9b4b350
Branches master
No related tags found
No related merge requests found
File added
File added
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class Lessons {
//Variable declaration
String lessonName;
int lessonsID;
String lessonContent;
private Quiz quizForThisLessons; //Composite Quiz class in Lessons class
ArrayList <Students> studentRecordForThisLesson=new ArrayList<>();
//Constructor for Lessons class
public Lessons(String lessonName, int lessonsID, String lessonContent) {
this.lessonName = lessonName;
this.lessonsID = lessonsID;
this.lessonContent = lessonContent;
}
public Lessons() {
}
//method for view lessons
void lessonView()
{
System.out.println("\t\t\t\t\t\t"+this.lessonName+"\n\t\t\t\t\t\t"+this.lessonsID+"\n\n\n"+this.lessonContent+"\n\n\n\t1.Take quiz\n\t2.Back to main menu\n\t3.Quit");
Scanner sc=new Scanner(System.in);
int ans= sc.nextInt();
lessonsViewProcessor(ans);
}
//method fo validating answer from lessonView page
void lessonsViewProcessor(int ans)
{
if(ans==1)
{
quizLoader();
}
else if(ans==2)
{
Main.main_display();
}
}
//Loading Page
void loadingPage()
{
System.out.println("Please wait ");
for(int i=0;i<5;i++) {
System.out.print(".");
try {
TimeUnit.SECONDS.sleep(1);
} catch (Exception e) {
}
}
}
//Loading Quiz
void quizLoader()
{
if(this.lessonsID==2101)
{
quizForThisLessons=new Quiz();
quizForThisLessons.setQuizNAme("Quiz on"+this.lessonName);
System.out.println("\n\t\t\t\t\t\t"+quizForThisLessons.getQuizNAme());
quizForThisLessons.SetQuizForCourseOne();
quizForThisLessons.setRandomQuestions();
studentRecordForThisLesson.add(quizForThisLessons.showingRandomQuiz(this.lessonName,lessonsID));
Main.main_display();
}
else
{
quizForThisLessons=new Quiz();
quizForThisLessons.setQuizNAme("Quiz on "+this.lessonName);
System.out.println("\n\t\t\t\t\t\t"+quizForThisLessons.getQuizNAme());
quizForThisLessons.SetQuizForCourseTwo();
studentRecordForThisLesson.add(quizForThisLessons.showingQuiz(this.lessonName,lessonsID));
Main.main_display();
}
}
/*Show Full student List*/
void courseView()
{
System.out.println("List of students who took "+this.lessonName+" course previously");
for (int i=0;i<studentRecordForThisLesson.size();i++)
{
System.out.println(i+1+"."+studentRecordForThisLesson.get(i).studentsName);
}
loadingPage();
Main.main_display();
}
/* void studentView()
{
for (int i=0;i<studentRecordForThisLesson.size();i++)
{
System.out.println(i+1+". Student Name is"+studentRecordForThisLesson.get(i).studentsName+"\t student ID:"+studentRecordForThisLesson.get(i).studentsID);
System.out.println("\tCourse Name \t\tMarks");
for(int k=0;k<studentRecordForThisLesson.get(i).CourseList.size();k++)
{
System.out.println("\t"+studentRecordForThisLesson.get(i).CourseList.get(k)+"\t\t"+studentRecordForThisLesson.get(i).marks.get(k));
}
}
loadingPage();
Main.main_display();
}*/
}
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
final static String username="COMSC";
final static int password=12345;
static String lessonOneName="Java";
static int lessonOneID=2101;
static String lessonOneContent="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sedr do eiusmod deis tempor incididunt ut labore et dolore kengan darwin doerski token.\n" +
"dover lipsum lorem and the others.";
static String lessonTwoName="Spring Boot";
static int lessonTwoID=2102;
static String lessonTwoContent="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sedr do eiusmod deis tempor incididunt ut labore et dolore kengan darwin doerski token.\n" +
"dover lipsum lorem and the others.";
static ArrayList <Lessons> lessonsArrayList=new ArrayList<>();
/*Functions for showing all the menu page STARTS here*/
static void main_display()
{
/*Main menu page for selecting next operation*/
System.out.println("\n### Welcome to Cardiff University Educational Resource Center ###");
System.out.println("\n \n");
System.out.println("\t\t\t\t\t\tPlease Choose Any Option");
System.out.println("\t1.Take lessons\n\t2.View Attendee List\n\t3.quit the program\n\n\n\tPress option no 3 or press q to quit" +
"\n\n\nThank you for Visiting Cardiff University Educational Resource Center");
Scanner sc=new Scanner(System.in);
var ans=sc.next(); //taking input from user
inputProcessing(ans); //input processing function
}
//function for choosing lessons
static void lessonChoicePage()
{
System.out.println("\t\t\t\t\t\tChoose Your lesson\n\t1."+lessonsArrayList.get(0).lessonName+"\n\t2."+lessonsArrayList.get(1).lessonName+"\n\t3.Main menu\n\t4.exit");
Scanner sc=new Scanner(System.in);
String ans=sc.next();
lessonChoiceProcessor(ans);
}
//function for logging page
static void logging()
{
Scanner sc=new Scanner(System.in);
String userNameInput;
int passWordInput;
System.out.println("\n\t**Please check read me file for credential**\n\n");
System.out.println("Please enter you username");
userNameInput=sc.next();
System.out.println("Please enter you password");
passWordInput=sc.nextInt();
if(passwordValidation(userNameInput,passWordInput)==true)
{
showAttendeeMenu();
}
else {
System.out.println("wrong password!try again");
logging();
}
}
/*Show the list of students who took lessons previously*/
static void showAttendeeMenu()
{
/* Scanner sc=new Scanner(System.in);
System.out.println("Choose your view\n\t1.Course view\n\t2.Student View ");
int ans=sc.nextInt();
viewChoiceProcessor(ans);*/
lessonsArrayList.get(0).courseView();
lessonsArrayList.get(1).courseView();
System.out.println("\n\n Enter Your Option\n\t1.Main menu\n\t2.Quit");
Scanner sc=new Scanner(System.in);
int ans =sc.nextInt();
viewChoiceProcessor(ans);
}
/*Functions for showing all the menu page ENDS here*/
/*Functions for processing all the choices STARTS here*/
//function for processing main menu choice
static void inputProcessing(String ans)
{
if (ans.equals("1"))
{
lessonChoicePage(); //passing objects of lessons class too lesson choice page
}
else if (ans.equals("2"))
{
logging();
}
else if (ans.equals("3")|| ans.equals("q"))
{
System.exit(0); //exiting program with error code 0
}
else
{
System.out.println("\tPlease enter valid input. ex: 1,2 ..");
main_display();
}
}
//function for processing lessonChoicePage ans
static void lessonChoiceProcessor(String ans)
{
if(ans.equals("1"))
{
lessonsArrayList.get(0).lessonView();
}
else if (ans.equals("2"))
{
lessonsArrayList.get(1).lessonView();
}
else if (ans.equals("3"))
{
main_display( );
}
else if (ans.equals("4"))
{
System.exit(0);
}
else {
System.out.println("Wrong Input\nChoose again");
lessonChoicePage();
}
}
//password username validation function
static boolean passwordValidation(String name,int pass)
{
if(name.equals(username)&& pass==password)
{
return true;
}
else
{
return false;
}
}
//view type choice processor
static void viewChoiceProcessor(int ans)
{
if(ans==1)
{
main_display();
}
else
{
System.exit(0);
}
}
/*Functions for processing all the choices ENDS here*/
/*Storing the two objects*/
static void storeTheLessons(Lessons lessonOne,Lessons lessonTwo)
{
lessonsArrayList.add(lessonOne);
lessonsArrayList.add(lessonTwo);
}
public static void main(String[] args)
{
Lessons lessonsOne=new Lessons(lessonOneName,lessonOneID,lessonOneContent);
Lessons lessonsTwo=new Lessons(lessonTwoName,lessonTwoID,lessonTwoContent);
storeTheLessons(lessonsOne,lessonsTwo);
main_display();
}
}
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class Quiz {
String quizNAme;
ArrayList <String> questions=new ArrayList<>();
ArrayList <Integer> answer=new ArrayList<>();
ArrayList <String> randomQuestions=new ArrayList<>();
ArrayList <Integer> randomAnswer=new ArrayList<>();
/*Loading static Ques for course 1*/
void SetQuizForCourseOne()
{
questions.add("Private Can be accessed from only ____?\n1.Class\t\t2.Withing Package\n3.Within subclass\t\t4.Outside Package");
answer.add(1);
questions.add("A method can be accessed by static function.\n1.Yes\t\t2.No");
answer.add(2);
questions.add("How many principles in OOP?\n1.1\t\t2.2\n3.3\t\t4.4");
answer.add(4);
questions.add("In array more spaces can be added after declaration?\n1.Yes\t\t2.No");
answer.add(2);
questions.add("Finally is used to ......\n1.To final a variable\t\t2.To Final a object\n3.Finally execute after handling exception");
answer.add(3);
questions.add("Hash map can have duplicate Value\n1.Yes\t\t2.No");
answer.add(2);
questions.add("Array list can be sorted depending on the variable \n1.Yes\t\t2.No");
answer.add(1);
}
/*Loading static Ques for course 2*/
void SetQuizForCourseTwo()
{
questions.add("What is Base dependencies for Spring Boot?\n\t1.devtools\t2.spring web");
answer.add(2);
questions.add("Spring boot and Spring mvc has no difference\n1.Yes\t\t2.No");
answer.add(2);
questions.add("Spring boot only works with tomcat server\n1.True\t\t2.False");
answer.add(2);
questions.add("In spring boot there are support for security\n1.True\t\t2.false");
answer.add(2);
questions.add("which database can be used in spring boot\n1.Mysql\t\t2.h2\n3.MongoDb\t\t4.All of them");
answer.add(3);
}
/*Random ques generator*/
void setRandomQuestions()
{
randomAnswer.clear();
randomQuestions.clear();
int randomNumber;
ArrayList <Integer> storeQues=new ArrayList<>();
Random rand =new Random();
for(int i=0;i<5;)
{
randomNumber=rand.nextInt(7);
if(storeQues.contains(randomNumber))
{
}
else
{
storeQues.add(randomNumber);
randomQuestions.add(questions.get(randomNumber));
randomAnswer.add(answer.get(randomNumber));
i++;
}
}
storeQues.clear();
}
/*Loading page*/
void loadingPage()
{
System.out.println("Please wait ");
for(int i=0;i<5;i++) {
System.out.print(".");
try {
TimeUnit.SECONDS.sleep(1);
} catch (Exception e) {
}
}
}
public String getQuizNAme() {
return quizNAme;
}
public void setQuizNAme(String quizNAme) {
this.quizNAme = quizNAme;
}
//method for displaying quiz and processing the answer
Students showingQuiz(String courseName,int lessonID)
{
int studentAns;
int correctAns;
Scanner sc=new Scanner(System.in);
int quizMark=0;
for(int i=0;i<5;i++)
{
studentAns=0;
System.out.println(i+1+"."+questions.get(i));
studentAns=sc.nextInt();
correctAns=answer.get(i);
if(studentAns==correctAns) //Validating Student ans
{
System.out.println("\nCorrect\n\n");
quizMark++;
}
else
{
System.out.println("\nWrong! Correct answer is "+correctAns+"\n\n");
}
}
Students students=new Students();
students=studentsRecordCollection(quizMark,students,lessonID);
students.CourseList.add(courseName);
return students;
}
//Showing Random Ques
Students showingRandomQuiz(String courseName,int lessonID)
{
int studentAns;
int correctAns;
Scanner sc=new Scanner(System.in);
int quizMark=0;
for(int i=0;i<5;i++)
{
studentAns=0;
System.out.println(i+1+"."+randomQuestions.get(i));
studentAns=sc.nextInt();
correctAns=randomAnswer.get(i);
if(studentAns==correctAns) //Validating Student ans
{
System.out.println("\nCorrect\n\n");
quizMark++;
}
else
{
System.out.println("\nWrong! Correct answer is "+correctAns+"\n\n");
}
}
Students students=new Students();
students=studentsRecordCollection(quizMark,students,lessonID);
students.CourseList.add(courseName);
return students;
}
/*Collecting student Information after completing the quiz*/
Students studentsRecordCollection(int mark,Students students,int lessonId)
{
Scanner sc=new Scanner(System.in);
System.out.println("Please Enter Your Name");
students.studentsName=sc.next();
System.out.println("Please Enter Your ID");
students.studentsID=sc.nextInt();
System.out.println("Thank you "+students.studentsName+" for you co-operation");
students.marks.add(-1);
students.marks.add(-1);
if(lessonId==2101)
{
students.marks.add(0,mark);
}
else
{
students.marks.add(1,mark);
}
System.out.println("\nYour Mark is "+mark+" out of 5");
loadingPage();
return students;
}
}
import java.util.ArrayList;
public class Students {
String studentsName;
int studentsID;
ArrayList <Integer> marks=new ArrayList<>();
ArrayList <String> CourseList =new ArrayList<>();
}
File added
File added
# Educational Resource
# Educational Resouce
Educational Resource is a java command line project for Student lesson and quiz
## Installation
The Project is compatible with JDK 11.0.11
The Required command for running the project is
```bash
java -jar 21114366.jar
```
## Features
1. Detailed Menu
2. Random question generator for lesson One
3. Log in feature for securely accessing data
## Credential For Login
username-COMSE
password-12345
## Developed By
Furkan Alahi
Sudent ID-21114366
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment