PDA

View Full Version : School Essentials Basic Quiz Program



Emily
December 4th, 2010, 03:14
Download Link: Only the registered members can see the link.


Or:

create packages:


school.math
school.science
school.util
In School.math

create a class called

MathDeclare.java


package school.math;

public class MathDeclare {
/**
* @author Emily
*/

/*
* The number of Correct Answers You Have
*/
public static int scoreCorrect;

/*
* The number of Incorrect Answers You Have
*/
public static int scoreIncorrect;

/*
* The Questions being ask, it is sent as an arrray
* that way we can save space, and make it look good
*/
public static String question [] = {
"Factor (X^2 - 1)",
"Answer this question False",
"One Plus One Equals?",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};

/*
* The Correct Answer to the question asked, also sent as an array
* so that we can svave space, and make it look good
*/
public static String[] correctAnswer = {
"(X+1)(X-1)",
"False",
"2",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};

}
And then create another file called
MathQuiz.java


package school.math;

import java.util.Scanner;

import school.util.Misc;

public class MathQuiz {

/**
* @author Emily
*/

public static void main(String args[]) {
Scanner player = new Scanner(System.in);
String Answer;
int random = Misc.random(10);
System.out.println("Question:");
System.out.println(""+MathDeclare.question[random]);
System.out.println("Answer:");
Answer = player.next();
if (Answer.equals(MathDeclare.correctAnswer[random])) {
MathDeclare.scoreCorrect += 1;
System.out.println("Correct!");
} else {
MathDeclare.scoreIncorrect += 1;
System.out.println("Incorrect!");
System.out.println("Correct Answer: "+MathDeclare.correctAnswer[random]);
}
}


}


Now, in school.science

create a class:

ScienceDeclare.java


package school.science;

public class ScienceDeclare {

/**
* @author Emily
*/

public static int scoreCorrect;

public static int scoreIncorrect;

public static String question [] = {
"Answer this question True",
"Answer this question False",
"One Plus One Equals?",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};

public static String[] correctAnswer = {
"True",
"False",
"2",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};


}
Now create a file in the same package
ScienceQuiz.java


package school.science;

import java.util.Scanner;

import school.util.Misc;

public class ScienceQuiz {

/**
* @author Emily
*/

public static void main(String args[]) {
Scanner player = new Scanner(System.in);
String Answer;
int random = Misc.random(10);
System.out.println("Question:");
System.out.println(""+ScienceDeclare.question[random]);
System.out.println("Answer:");
Answer = player.next();
if (Answer.equals(ScienceDeclare.correctAnswer[random])) {
ScienceDeclare.scoreCorrect += 1;
System.out.println("Correct!");
} else {
ScienceDeclare.scoreIncorrect += 1;
System.out.println("Incorrect!");
System.out.println("Correct Answer: "+ScienceDeclare.correctAnswer[random]);
}
}


}
Now in school.util create a class:
Misc.java


package school.util;

public class Misc {

/**
* @author Emily
*/

public static int random(int range) {
return (int)(Math.random() * (range + 1));
}

}

Basically uses array for the question, and correct answer, change the


int random = Misc.random(10);


To how ever many of questions you have, it'll randomly select one on startup to ask you.

Credits:
Emily


You can use this if you want, or improve it, i could care less. I just thought of the idea after a nap so i decided to make it quick.

Rate/Hate/Comment

A Panda
December 4th, 2010, 03:16
Looks very complex and out of my league :3, not gonna bother trying it ;p.

But i hope some people do.

GkCha0z
December 4th, 2010, 03:16
thats kool 8/10 because i hate school lol

Emily
December 4th, 2010, 03:18
Looks very complex and out of my league :3, not gonna bother trying it ;p.

But i hope some people do.

That is actually extremely easy, anyone with a basic grasp on java can do this easily

A Panda
December 4th, 2010, 03:23
That is actually extremely easy, anyone with a basic grasp on java can do this easily

So i bet i could, i just do not want to bother ;)

Steve
December 4th, 2010, 05:35
Didnt really look at it all but mathdeclare and sciencedeclare? Why not MathConstants, and ScienceConstants. Mathdeclare and sciencedeclare just sounds, wrong :/.

Mystic Flow
December 4th, 2010, 15:12
That looks like total shit

Your @author tag is in the wrong spot :fp:
your documentation sucks
Your code sucks
Your naming sucks

l2 2d array, l2 proper random method using random util (no rsps random method bullshit), l2 actually use arrays and l2 local variables


i mildly digress, do you actually know java outside of rsps?

This all looks like something taken out of rsps skills lol

ScienceDeclare <--- LoL

MrCanada
December 4th, 2010, 15:13
That looks like total shit

Your @author tag is in the wrong spot :fp:
your documentation sucks
Your code sucks
Your naming sucks

l2 2d array, l2 proper random method using random util (no rsps random method bullshit), l2 actually use arrays and l2 local variables



This all looks like something taken out of rsps skills lol

Raped, that know it all. (Emily)

Faab234
December 4th, 2010, 19:14
OH AND DIDN'T I EXPLAIN WHAT THE FINAL MODIFIER WAS A FEW DAYS AGO??

Only the registered members can see the link.

OH YEAH

Class: You can't subclass it
Method: You can't override it.
Variable: You can't change the values.

Steve
December 4th, 2010, 19:20
Class: You can't subclass it
Method: You can't override it.
Variable: You can't change the values.

Yeah so i'm pretty sure he meant that she could've changed all this


public static String question [] = {
"Factor (X^2 - 1)",
"Answer this question False",
"One Plus One Equals?",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};

/*
* The Correct Answer to the question asked, also sent as an array
* so that we can svave space, and make it look good
*/
public static String[] correctAnswer = {
"(X+1)(X-1)",
"False",
"2",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};
And w/e was in "sciencedeclare" to final.

Faab234
December 4th, 2010, 19:21
Yeah so i'm pretty sure he meant that she could've changed all this


public static String question [] = {
"Factor (X^2 - 1)",
"Answer this question False",
"One Plus One Equals?",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};

/*
* The Correct Answer to the question asked, also sent as an array
* so that we can svave space, and make it look good
*/
public static String[] correctAnswer = {
"(X+1)(X-1)",
"False",
"2",
"Hi",
"Bye",
"LOL",
"Maybe",
"Leave",
"Mean",
"Pie",
"Ask again",
"kk",
};
And w/e was in "sciencedeclare" to final.

Better idea to get the answers, decompile it.

Mystic Flow
December 4th, 2010, 20:35
Better idea to get the answers, decompile it.

Obfuscation exists you know

Faab234
December 5th, 2010, 09:23
Obfuscation exists you know

Deobfuscation exists you know

Mystic Flow
December 5th, 2010, 18:07
Deobfuscation exists you know

Yes, because someone will waste more time deobfuscating the code rather then answer the questions themselves, there are some heavy obfuscater's that take some time to deobfuscate, and if you actually figure out how to deobfuscate it, then you should have the knowledge to answer simple questions :fp:

Faab234
December 6th, 2010, 06:41
Yes, because someone will waste more time deobfuscating the code rather then answer the questions themselves, there are some heavy obfuscater's that take some time to deobfuscate, and if you actually figure out how to deobfuscate it, then you should have the knowledge to answer simple questions :fp:

Lol, yes.


fair do's faab you are complete retard i meant change those fields to final and who the fuck would deobfuscate this bollucks anyway, it wouldn't even be worth decompiling.

Yes, I know that.

Trey
December 6th, 2010, 20:27
How about we stay on topic. Critique the code, not each other.

Mystic Flow
December 7th, 2010, 13:31
the code isn't worth anyone's time let alone worth criticising

this.

+ I love how Emily hasn't been able to reply to any of us, I think we lost her when we started posting rifk

Mystic Flow
December 7th, 2010, 21:13
Thou shalt not take the name of the lord thy God in vain

hint hint mystic

Oh my bad edited

Zykev2
December 7th, 2010, 21:34
How come Emily isn't going on here defending himself? Is it he finally knows when he is just not that great?

Cyberus
December 7th, 2010, 21:44
Because "he" isn't as immature as mostly everyone else on this thread.

Trey
December 7th, 2010, 21:46
Can we get back on topic please?

samuraiblood2
December 7th, 2010, 22:01
Why did you make a separate class for constants (ignoring the fact that they aren't defined as such)? Theres so many obvious ways this could be improved that they aren't worth listing.


Can we get back on topic please?

What exactly is the topic?

Trey
December 7th, 2010, 22:07
Why did you make a separate class for constants (ignoring the fact that they aren't defined as such)? Theres so many obvious ways this could be improved that they aren't worth listing.



What exactly is the topic?

The program and code provided. Calling each other names and insulting the OP doesn't have anything to do with the program provided, no matter how bad it is. The last bunch of posts have basically nothing to do with the topic. If you don't want to criticize the code, then don't post.

Since this had led to nothing constructive, closed.