The programming thread!
Moderator: EG Members
- War Machine
- Tastes like burning!
- Posts: 1463
- Joined: Sun Apr 08, 2007 7:30 pm
- Location: San Diego now
Re: The programming thread!
That Usuario package is something that he found either on a disc or something he downloaded. It's some class he uses to take input from the user and print to the console (e.g. Usuario.entero takes in an integer from the keyboard input). Just replace that crap with the Scanner class and System.out.print I guess.
@Rolos: Throw that Usuario package in the garbage, you already have all those functions in Java.
@Rolos: Throw that Usuario package in the garbage, you already have all those functions in Java.
"Clearly my escape had not been anticipated, or my benevolent master would not have expended such efforts to prevent me from going. And if my departure displeased him, then that was a victory, however small, for me." - Raziel
Re: The programming thread!
Right, right.
I got that package from a friend. It´s the one they use to teach programming to engineers in "Pontificia Universidad Catolica de Chile", which he attends.
The only reason I´m using it is because I can´t, for the life of me, find a single thing online about input-output comands in java. Perhaps it´s considered so damn basic no one´s thought of telling anyone else about, perhaps I´m just a moron who doesn´t know how to navigate Java libraries.
I´m beginning to suspect the latter is far more likely.
Pointless garbage I just can´t seem to skip when writing anything:
[spoiler]Either way, I´d be willing to pay 3 fresh human organs for that information. The state they arrive in will depend on a number of factors I can´t really go into right now, but I promise they will show up at your front door, eventually.
Ugh.
What a retarded thing to offer.
Anyway, how I do that? The input thing, I mean.
Python, how I miss you! All I had to do was write input (" ") or eval(input(" ")) and that was it.
But now I´m forced to us strange, alien packages to do that.
Java is a cruel and whimsical mistress.[/spoiler]
[Laconic]Input. Java. How? Will change program so others can double-check code. [/Laconic]
P.S. Sorry for the spelling. Not my computer.
I got that package from a friend. It´s the one they use to teach programming to engineers in "Pontificia Universidad Catolica de Chile", which he attends.
The only reason I´m using it is because I can´t, for the life of me, find a single thing online about input-output comands in java. Perhaps it´s considered so damn basic no one´s thought of telling anyone else about, perhaps I´m just a moron who doesn´t know how to navigate Java libraries.
I´m beginning to suspect the latter is far more likely.
Pointless garbage I just can´t seem to skip when writing anything:
[spoiler]Either way, I´d be willing to pay 3 fresh human organs for that information. The state they arrive in will depend on a number of factors I can´t really go into right now, but I promise they will show up at your front door, eventually.
Ugh.
What a retarded thing to offer.
Anyway, how I do that? The input thing, I mean.
Python, how I miss you! All I had to do was write input (" ") or eval(input(" ")) and that was it.
But now I´m forced to us strange, alien packages to do that.
Java is a cruel and whimsical mistress.[/spoiler]
[Laconic]Input. Java. How? Will change program so others can double-check code. [/Laconic]
P.S. Sorry for the spelling. Not my computer.
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
- DrPepperPro
- Dirty Sennin
- Posts: 2216
- Joined: Mon Aug 20, 2007 5:16 pm
Re: The programming thread!
Fixed.Rolos wrote:Either way, I´d be willing to pay 3 fresh human organs for that information. The state they arrive in will depend on a number of factors I can´t really go into right now, but I promise they will show up at your front door, eventually.
Ugh.
What a retarded thing to offer.
Pointless garbage I just can´t seem to skip when writing anything:
[spoiler]Right, right.
I got that package from a friend. It´s the one they use to teach programming to engineers in "Pontificia Universidad Catolica de Chile", which he attends.
The only reason I´m using it is because I can´t, for the life of me, find a single thing online about input-output comands in java. Perhaps it´s considered so damn basic no one´s thought of telling anyone else about, perhaps I´m just a moron who doesn´t know how to navigate Java libraries.
I´m beginning to suspect the latter is far more likely.
Anyway, how I do that? The input thing, I mean.
Python, how I miss you! All I had to do was write input (" ") or eval(input(" ")) and that was it.
But now I´m forced to us strange, alien packages to do that.
Java is a cruel and whimsical mistress.
[Laconic]Input. Java. How? Will change program so others can double-check code. [/Laconic]
P.S. Sorry for the spelling. Not my computer.[/spoiler]
Re: The programming thread!
I would personally use JFrames and ActionListener for user input. I'll try to whip up a little example in a bit.
EDIT:
O.K., small example here with JFrame and ActionListener.
This is the JFrame class.
Here's the main class
Your code would of course include a lot of methods for the frame and stuff happening in the main program, but that's the basic idea. Lemme know if I messed anything up or wasn't clear on something. Looking forward to your quiz
EDIT:
O.K., small example here with JFrame and ActionListener.
This is the JFrame class.
Code: Select all
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
//need these to use JFame and ActionListener. I don't remember which is for which.
public class TehFrame extends JFrame implements ActionListener //your class uses JFame as a base, letting you use all the sexy JFrame stuff.
{ //uses ActionListener to react to things the user does
//set the width and height so you can change them here if you need to
final int WIDTH = 200;
final int HEIGHT = 300;
//initialize components
JLabel question = new JLabel("Sup");
JTextField answer = new JTextField(10);
JButton pressMe = new JButton("Press Me!");
JLabel sup = new JLabel("");
public TehFrame()
{
super("Title Goes Here");
setSize(WIDTH, HEIGHT);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
add(question);
add(answer);
add(pressMe);
add(sup);
pressMe.addActionListener(this); //tells the program to go to the actionPerformed method when this button is pressed
}
public void actionPerformed(ActionEvent e)
{
String said = answer.getText();
String wussup = said + " is up.";
sup.setText(wussup);
}
}
Code: Select all
public class example
{
public static void main(String[] args)
{
TehFrame newFrame = new TehFrame();
}
}
Your code would of course include a lot of methods for the frame and stuff happening in the main program, but that's the basic idea. Lemme know if I messed anything up or wasn't clear on something. Looking forward to your quiz
Last edited by Mail on Tue Apr 19, 2011 10:27 pm, edited 1 time in total.
-
- notanewb
- Posts: 73
- Joined: Tue Feb 22, 2011 4:40 pm
Re: The programming thread!
I assume he meant for command line input/output
input:
output:
If you want GUI input/output, then the Swing API has the required classes:
Jlabel, JTextField, JTextArea, JComboBox etc
PS ship the body parts to "1600 Pennsylvania Ave NW Washington, DC 20500"
input:
Code: Select all
import Scanner;//err check the import package stuff or have an IDE do it for you
...
private Scanner input;
...
input.nextInt();//returns next integer entered on command line, should error I believe if not proper input
input.next();//returns whatever the user enter on the command line
Code: Select all
System.out.print("Prints this stuff");//prints any string without a new line to the command line
System.out.println("Prints this stuff and a new line");
Jlabel, JTextField, JTextArea, JComboBox etc
PS ship the body parts to "1600 Pennsylvania Ave NW Washington, DC 20500"
Re: The programming thread!
Thanks for the help, guys.
I'll make the changes this friday.
I won't be able to dedicate much of the weekend to this program, though, the amount of homework I've been piling up in my closet is ungodly.
By the way, the applet thing sounds interesting. As soon as I find out what they are, apart from a remarkably chewy-sounding word, I'll get to it.
@DrPepperPro: You really like doing that, don't you?
I'll make the changes this friday.
I won't be able to dedicate much of the weekend to this program, though, the amount of homework I've been piling up in my closet is ungodly.
By the way, the applet thing sounds interesting. As soon as I find out what they are, apart from a remarkably chewy-sounding word, I'll get to it.
@DrPepperPro: You really like doing that, don't you?
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
- DrPepperPro
- Dirty Sennin
- Posts: 2216
- Joined: Mon Aug 20, 2007 5:16 pm
Re: The programming thread!
I'm just interacting with the Rolos Application.
- War Machine
- Tastes like burning!
- Posts: 1463
- Joined: Sun Apr 08, 2007 7:30 pm
- Location: San Diego now
Re: The programming thread!
Don't, you'll brake him (or he'll break himself, I don't know).DrPepperPro wrote:I'm just interacting with the Rolos Application.
@Rolos
JFrame will work just as well, but it's a graphical interface (windows and text boxes, etc.), so you have to worry about those things and it's a little more complicated (not that much though). With the Scanner class you can work in the console, so I suggest start with the Scanner class and then move onto JFrame if you like. Here's how to use the Scanner class to take input from the user:
(Unless I made a mistake you should be able to copy all this into a file, compile and run.)
Code: Select all
import java.util.Scanner;
public class InputOutputProgram
{
public static void main (String[] args)
{
Scanner keyboard = new Scanner(System.in); //Make an instance of a Scanner that uses System.in as an InputStream.
String name; //String to hold name that user will input
int age; //Integer to hold age that user will input
System.out.print("Please enter your name: "); //Write a message on the console.
name = keyboard.nextLine() //Take whatever the user typed as a string and save it into 'name'.
//The nextLine() function reads in the whole line, while the
//next() function only reads in the next token, which might
//work the exact same way in this situation.
System.out.print("Please enter your age: "); //Write another message.
age = keyboard.nextInt(); //Take input from the user and save it as an integer in 'age'.
//Note: If you type something that's not a number, the program will
//throw an exception (i.e. crash) because it is expecting an integer.
System.out.println("\n\nYour name is " + name + " and your age is " + age); //Final message.
}
}
http://download.oracle.com/javase/6/doc ... anner.html
"Clearly my escape had not been anticipated, or my benevolent master would not have expended such efforts to prevent me from going. And if my departure displeased him, then that was a victory, however small, for me." - Raziel
Re: The programming thread!
Yeah, you should get the actual program done with scanner first. Then you can create the sexy interface with JFrame or Applet. They're pretty much the same thing except you can put an applet on a website.
Also, are you using anything to help you create the program or just straight up command line compiling from text editors? There are a bunch of free development kits that help you create and debug programs (jGRASP, JCreator). They make it much easier to catch mistakes, so you should consider using one if you aren't already.
Also, are you using anything to help you create the program or just straight up command line compiling from text editors? There are a bunch of free development kits that help you create and debug programs (jGRASP, JCreator). They make it much easier to catch mistakes, so you should consider using one if you aren't already.
Re: The programming thread!
I'm using ECLIPSE, and hate every second of it, for reasons not entirely unlike the ones that made me completely renounce to Microsoft Word. I know it's incredibly useful to have any syntactical mistakes pointed out whilst writing the code, but it still annoys the hell out of me.
[spoiler]My thought processes while using it can be accurately described as follows:
SHUT THE FUCK UP, YOU GODDAMN MACHINE! I'll import as many packages as I like, create as many never-referenced variables as I wish! Don't you dare double-guess me, you foul ethereal contraption! Who are you to deny me the right to add a 'Don_Flamboyant_Spanish_Gentilhombre = true' to every single class I make? You are nothing! NOTHING! I CURSE YOU! I CURSE YOUR FAMILY! I CURSE YOUR FAMILY'S PETS! I CURSE THE PEOPLE WHO RAISED, GROOMED AND TOOK CARE OF THOSE PETS UNTIL THEY REACHED AN AGE AT WHICH THE LIKELIHOOD OF THEM BEING BOUGHT AT A LOCAL PET STORE WAS HIGH! I CURSE THE FREE-MARKET SYSTEM, WHICH ALLOWS FOR - Oh, thanks for pointing that out. Really missed that comma there. Wait.
...
....
DAMN YOUUUUUUUUUUUUUUUUUUUU![/spoiler]
Ahem.
Friday.
@Sandimas: Why would you do something like that? Just... why?
@DrPepperPro: I don't really mind, as long as it's funny. Like that Diogenes thing. Man, that was genius. You do realize I'm going to steal that idea and pass it off as my own, don't you?
[spoiler]My thought processes while using it can be accurately described as follows:
SHUT THE FUCK UP, YOU GODDAMN MACHINE! I'll import as many packages as I like, create as many never-referenced variables as I wish! Don't you dare double-guess me, you foul ethereal contraption! Who are you to deny me the right to add a 'Don_Flamboyant_Spanish_Gentilhombre = true' to every single class I make? You are nothing! NOTHING! I CURSE YOU! I CURSE YOUR FAMILY! I CURSE YOUR FAMILY'S PETS! I CURSE THE PEOPLE WHO RAISED, GROOMED AND TOOK CARE OF THOSE PETS UNTIL THEY REACHED AN AGE AT WHICH THE LIKELIHOOD OF THEM BEING BOUGHT AT A LOCAL PET STORE WAS HIGH! I CURSE THE FREE-MARKET SYSTEM, WHICH ALLOWS FOR - Oh, thanks for pointing that out. Really missed that comma there. Wait.
...
....
DAMN YOUUUUUUUUUUUUUUUUUUUU![/spoiler]
Ahem.
Friday.
@Sandimas: Why would you do something like that? Just... why?
@DrPepperPro: I don't really mind, as long as it's funny. Like that Diogenes thing. Man, that was genius. You do realize I'm going to steal that idea and pass it off as my own, don't you?
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
- DrPepperPro
- Dirty Sennin
- Posts: 2216
- Joined: Mon Aug 20, 2007 5:16 pm
Re: The programming thread!
ya that thing I did that you mentioned was pretty neat, I wonder if the Diogenes guy thought that could happen? Then again he didn't know about copy paste or such. What would spam bots be to him?
cough. Ugh I'm bored. Berserk coming out in a couple days though. We'll include your program in each release, in fact start making it so it can display images, we'll just release chapters in a java app and force them to answer a question to read each page. And no I'm not trying to be funny, just stupid/bored talk whatever. Oh but now I've gone and went meta, things can never be the same in this post. I don't even know why I posted this post, it should've just stayed in my head to die at a somewhat later date, now it will have to wait for this thread to.
cough. Ugh I'm bored. Berserk coming out in a couple days though. We'll include your program in each release, in fact start making it so it can display images, we'll just release chapters in a java app and force them to answer a question to read each page. And no I'm not trying to be funny, just stupid/bored talk whatever. Oh but now I've gone and went meta, things can never be the same in this post. I don't even know why I posted this post, it should've just stayed in my head to die at a somewhat later date, now it will have to wait for this thread to.
Re: The programming thread!
Heh. Well. If you think about it, Eclipse is stored as electrical charge on your hard disk. Which means that it's made of pure energy. Which means it's technically achieved a higher state of existence than you. So you should probably listen when it gives you advice.
Also, it's generally a bad idea to create non-referenced variables as they just clutter up the program. And while a 'bool Don_Flamboyant_Spanish_Gentilhombre = true' might be aesthetically pleasing and/or humorous to you, it probably wouldn't help with the organization and execution of the program.
So you gonna put something up friday? I'm looking forward to it
@DrPepperPro
That would be such a dick move.
....
You should totally do it.
Also, it's generally a bad idea to create non-referenced variables as they just clutter up the program. And while a 'bool Don_Flamboyant_Spanish_Gentilhombre = true' might be aesthetically pleasing and/or humorous to you, it probably wouldn't help with the organization and execution of the program.
So you gonna put something up friday? I'm looking forward to it
@DrPepperPro
That would be such a dick move.
....
You should totally do it.
Re: The programming thread!
There's no such thing as pure energy.
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
Re: The programming thread!
That....depends on how you define energy. As defined by physical science, you are correct. However, to many people the word energy has taken on additional metaphysical meaning (Chi, Ki, spiritual energy) that isn't necessarily definable in a purely physical sense. Which means it can be its own distinct entity and therefore pure.
But yes. Your program is not pure energy. I'm sorry for suggesting it.
...how's the program coming?
But yes. Your program is not pure energy. I'm sorry for suggesting it.
...how's the program coming?
Re: The programming thread!
Just fixed the problem I had been having with the serialization.
It was just a quick fix, I'm definitely not dedicating more time to that particular activity today.
Tomorrow I'll change the input commands and get to writing the quiz program, then the questions.
Depending on whether I manage to finish this definitely not illegal thing I have to do today, I may start doing the graphical interface.
Chances of that happening are slim, though.
I know I've been fairly slow-paced about this, I apologize.
(Heh. No I don't. Disraeli would never permit such a thing.)
EDIT1:
Haven't really done anything new. Been working on something else.
Anyway, changed the input/output commands and got rid of the Usuario package.
Question Class:
[spoiler][/spoiler]
Questionaire Maker:
[spoiler][/spoiler]
I know, I know, I'll get to it. It's just that this other thing is kind of important. And difficult.
EDIT2: Done! Hahahahahaha! Oh, man, the exhilaration! I feel awesome! I put together a (semi)working program with nothing but bullshit and half-assed knowledge! Gotta start with the specifics of the berserk trivia now, but I'm finished as far as programming goes! Wooohooo!
Questionaire_O_Matic:
[spoiler][/spoiler]
EDIT3: Quick question: Has anyone ever worked with random numbers/binary converters summations/summatories?
Because I've been working with that the whole day and man, it is a BITCH.
Don't want any help, though, I'm just asking to know if there are any fellow randomers.
Here's a cool site dedicated to the subject, if anyone's interested: http://www.random.org
Also, totally awesome: http://plus.maths.org/content/omega-and ... as-no-toes
EDIT4: I am a moron.
EDIT5: Completely unrelated to Berserk, but since this is the programming thread, I might as well post it here.
(pseudo)RANDOM NUMBERS!
I wrote an algorithm that generates them. And then tells you how random they are.
Took me most of this weekend, and it's still a bug-ridden nightmare, but I made it.
[spoiler][/spoiler]
Most of the comments are in spanish, though.
I usually write/program everything in english, as I find it to be a good way to practice my redaction and language skills, but not this time.
Why?
I don't know.
(I'll proooobably do the questions tonight, but I won't upload them until I have the entire questionnaire done. It'd be boring otherwise, since I intend to do some modifications to the program for this particular questionnaire)
EDIT6: I've written about 0.5 of the total number of questions. Way more difficult than I thought it would be. Also, doing some modifications to the Question_O_Matic program, just for my own amusement.
Aaaand working on a program that tells you what input will provide the most random sequence of numbers, for that other program I did (which uses the current date and hour as a seed for the iterations, so it can be a bit predictable unless you give it the appropriate input).
It was just a quick fix, I'm definitely not dedicating more time to that particular activity today.
Tomorrow I'll change the input commands and get to writing the quiz program, then the questions.
Depending on whether I manage to finish this definitely not illegal thing I have to do today, I may start doing the graphical interface.
Chances of that happening are slim, though.
I know I've been fairly slow-paced about this, I apologize.
(Heh. No I don't. Disraeli would never permit such a thing.)
EDIT1:
Haven't really done anything new. Been working on something else.
Anyway, changed the input/output commands and got rid of the Usuario package.
Question Class:
[spoiler]
Code: Select all
import java.util.Scanner;
import java.io.ObjectOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.Serializable;
public class triviaQuestion_N implements Serializable{
/**instance variables:**/
String questionN;
String answer1;
String answer2;
String answer3;
String answer4;
boolean a, b, c, d;
int correctAnswer;
// question: Why am I always told that I should make these private?
public triviaQuestion_N(){
/**constructor:**/
Scanner keyboard = new Scanner(System.in);
System.out.println("Write question here:");
System.out.println(" ");
questionN= keyboard.nextLine();
System.out.println("Write answer 1 here:");
System.out.println(" ");
answer1= keyboard.nextLine();
System.out.println("Write answer 2 here:");
System.out.println(" ");
answer2= keyboard.nextLine();
System.out.println("Write answer 3 here:");
System.out.println(" ");
answer3= keyboard.nextLine();
System.out.println("Write answer 4 here:");
System.out.println(" ");
answer4= keyboard.nextLine();
a = b = c = d = false;
if (correctAnswer == 1){
a= true;
}//if user selects alternative 1 as the correct one
else {if(correctAnswer== 2){
b= true;
}//if user selects alternative 2 as the correct one
else {if(correctAnswer == 3){
c= true;
}//if user selects alternative 3 as the correct one
else {if(correctAnswer == 4){
d= true;
}//if user selects alternative 4 as the correct one}
}//else 3
}//else 2
}//else 1
}//constructor
public void TheCorrectAnsweris (){
if (a==true){
System.out.println(a);
}//if1
if (b==true){
System.out.println(b);
}//if2
if (c==true){
System.out.println(c);
}//if3
if (d==true){
System.out.println(d);
}//if3
}//TheCorrectAnsweris method
public void TheQuestionis (){
System.out.println(questionN);
System.out.println(" ");
}//Method to print out the question being asked.
public void ThePossibleAnswersare(){
System.out.println("A) "+ answer1);
System.out.println(" ");
System.out.println("B) "+ answer2);
System.out.println(" ");
System.out.println("C) "+ answer3);
System.out.println(" ");
System.out.println("D) "+ answer4);
System.out.println(" ");
}//method to tell you what the alternatives are.
}//class
Questionaire Maker:
[spoiler]
Code: Select all
import java.util.Scanner;
import java.io.Serializable;
import java.io.ObjectOutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class Questionaire_O_Maker implements Serializable {
public triviaQuestion_N[] excelent;
public triviaQuestion_N[] competent;
public triviaQuestion_N[] defficient;
public triviaQuestion_N[] functionallyRetarded;
public int numberOfQuestions;
public Questionaire_O_Maker (){
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter the desired number of questions");
System.out.println(" ");
numberOfQuestions= keyboard.nextInt();
excelent = new triviaQuestion_N[numberOfQuestions];
competent = new triviaQuestion_N[numberOfQuestions];
defficient = new triviaQuestion_N[numberOfQuestions];
functionallyRetarded = new triviaQuestion_N[numberOfQuestions];
for (int questionsWrittenSoFar=0; questionsWrittenSoFar<numberOfQuestions; questionsWrittenSoFar++){
excelent [questionsWrittenSoFar] = new triviaQuestion_N();
System.out.println("Questions written so far: "+(questionsWrittenSoFar+1));
}//for1
System.out.println("Questions of difficulty 4 are done!");
for (int questionsWrittenSoFar=0; questionsWrittenSoFar<numberOfQuestions; questionsWrittenSoFar++){
competent [questionsWrittenSoFar]= new triviaQuestion_N() ;
System.out.println("Questions written so far: "+(questionsWrittenSoFar+1));
}//for2
System.out.println("Questions of difficulty 3 are done!");
for (int questionsWrittenSoFar=0; questionsWrittenSoFar<numberOfQuestions; questionsWrittenSoFar++){
defficient [questionsWrittenSoFar]= new triviaQuestion_N();
System.out.println("Questions written so far: "+(questionsWrittenSoFar+1));
}//for3
System.out.println("Questions of difficulty 2 are done!");
for (int questionsWrittenSoFar=0; questionsWrittenSoFar<numberOfQuestions; questionsWrittenSoFar++){
functionallyRetarded [questionsWrittenSoFar]= new triviaQuestion_N();
System.out.println("Questions written so far: "+(questionsWrittenSoFar+1));
}//for4
System.out.println("Questions of difficulty 1 are done!");
System.out.println("Done with the questions!");
}//constructor
public static void main(String[] args) {
String filename = "writeNameOfQuestionaireHere.ser";
if(args.length > 0){
filename = args[0];}
System.out.println("Introduction to Quiz-writing program"); //Here you write whatever inane bullshit you'll greet the user with.
System.out.println("Instructions"); //pretty much self-explanatory
Questionaire_O_Maker writeNameOfQuestionaireHere = new Questionaire_O_Maker();// replace name of quiz
try{
FileOutputStream filestream = new FileOutputStream ("writeNameOfQuestionaireHere.ser");
ObjectOutputStream os = new ObjectOutputStream (filestream);
os.writeObject(writeNameOfQuestionaireHere);
os.close();}//close try
catch(IOException ex){
ex.printStackTrace();}//catch exceptions
}//main
}//Questionaire_O_Maker class
I know, I know, I'll get to it. It's just that this other thing is kind of important. And difficult.
EDIT2: Done! Hahahahahaha! Oh, man, the exhilaration! I feel awesome! I put together a (semi)working program with nothing but bullshit and half-assed knowledge! Gotta start with the specifics of the berserk trivia now, but I'm finished as far as programming goes! Wooohooo!
Questionaire_O_Matic:
[spoiler]
Code: Select all
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Scanner;
public class Questionaire_O_Matic {
//execute Questionaire_O_Maker and make list of questions
public static void main(String[] args) {
Questionaire_O_Maker Trivia = null;
try{
ObjectInputStream os = new ObjectInputStream (new FileInputStream ("writeNameOfQuestionaireHere.ser"));
Trivia = (Questionaire_O_Maker) os.readObject();}
catch(IOException ex){
ex.printStackTrace();
}//catch exceptions
catch (ClassNotFoundException e) {
e.printStackTrace();
}//imports all information from previously created questionaires
System.out.print("Introduction to Trivia"); //Here you write whatever inane bullshit you'll greet the user with.
System.out.print("Instructions"); //pretty much self-explanatory
Scanner keyboard = new Scanner(System.in);
int correct_answers= 0;
int functionally_Retarded= 0;
int excellent = 0;
int competent = 0;
int defficient = 0;
for (int i=0; i<Trivia.numberOfQuestions; i++){
excellent=10*(i+1);//how much each correct answer is worth, depending on difficulty
competent=8*(i+1);//how much each correct answer is worth, depending on difficulty
defficient=4*(i+1);//how much each correct answer is worth, depending on difficulty
functionally_Retarded=1*(i+1);//how much each correct answer is worth, depending on difficulty
correct_answers= 0;
if (correct_answers > competent){
Trivia.excelent[i].TheQuestionis();
Trivia.excelent[i].ThePossibleAnswersare();
System.out.println("And your answer is...?");
int User_Answer= keyboard.nextInt();
if(User_Answer == Trivia.excelent[i].correctAnswer){
correct_answers = correct_answers +10;}//check to see whether answer is correct or not
}//determines level of user so far and chooses an array of questions accordingly
if (correct_answers > defficient){
Trivia.competent[i].TheQuestionis();
Trivia.competent[i].ThePossibleAnswersare();
System.out.println("And your answer is...?");
int User_Answer= keyboard.nextInt();
if(User_Answer == Trivia.competent[i].correctAnswer){
correct_answers = correct_answers +8;}//check to see whether answer is correct or not
}//determines level of user so far and chooses an array of questions accordingly
if (correct_answers > functionally_Retarded){
Trivia.defficient[i].TheQuestionis();
Trivia.defficient[i].ThePossibleAnswersare();
System.out.println("And your answer is...?");
int User_Answer= keyboard.nextInt();
if(User_Answer == Trivia.defficient[i].correctAnswer){
correct_answers = correct_answers +4;}//check to see whether answer is correct or not
}//determines level of user so far and chooses an array of questions accordingly
if (correct_answers >= 0){
Trivia.functionallyRetarded[i].TheQuestionis();
Trivia.functionallyRetarded[i].ThePossibleAnswersare();
System.out.println("And your answer is...?");
int User_Answer= keyboard.nextInt();
if(User_Answer == Trivia.functionallyRetarded[i].correctAnswer){
correct_answers = correct_answers +1;}//check to see whether answer is correct or not
}//determines level of user so far and chooses an array of questions accordingly
}//this loop composes the entirety of the questionaire
System.out.println("Your total score is of: "+ correct_answers );
if(correct_answers > competent)
{System.out.println("Congratulations! Your score is excellent.");}// if your score is excellent you get this little message.
else{if(correct_answers > defficient)
{System.out.println("Congrats! Your score is just enough to pass.");}// if your score is that of a competent person you get this little message.
else {if (correct_answers > functionally_Retarded)
{System.out.println("Shame on you. Your score is deplorably low.");}// if your score is defficient you get this little message.
else{if (correct_answers > 0)
{System.out.println("Your performance is virtually indistinguishable from that of a particularly dense maccacus");}
else {{System.out.println("HAHAHAHAHAHAHAHAHAHAHHAHAHAHAHAHAAHAAAAA!.");}
}}}}// if your score is less than defficient you get this little message.
}//main
}//class
EDIT3: Quick question: Has anyone ever worked with random numbers/binary converters summations/summatories?
Because I've been working with that the whole day and man, it is a BITCH.
Don't want any help, though, I'm just asking to know if there are any fellow randomers.
Here's a cool site dedicated to the subject, if anyone's interested: http://www.random.org
Also, totally awesome: http://plus.maths.org/content/omega-and ... as-no-toes
EDIT4: I am a moron.
EDIT5: Completely unrelated to Berserk, but since this is the programming thread, I might as well post it here.
(pseudo)RANDOM NUMBERS!
I wrote an algorithm that generates them. And then tells you how random they are.
Took me most of this weekend, and it's still a bug-ridden nightmare, but I made it.
[spoiler]
Code: Select all
import java.util.Date;
import IIC1103Package.Usuario;
import Tarea1Package.*;
public class Random_Ejer_1
{int A;
int B;
int C;
int semilla;
public Random_Ejer_1(int vA, int vB, int vC)
{Date now = new Date();
semilla = (int) ((now.getTime())%vC);
A = vA;
B = vB;
C = vC;}//Random constructor
public int next(){
semilla = (A*semilla + B)%C;
return semilla ;}//next method
public int nextInterval(int min, int max)
{semilla = (A*semilla + B)%C;
return min + semilla%(max-min+1);}//next Interval method
public double test (int n){
Random_Ejer_1 X = new Random_Ejer_1(A,B,C);
double x0= 0;
double x1= 0;
double x2= 0;
double x3= 0;
double x4= 0;
double x5= 0;
double x6= 0;
double x7= 0;
double binarioADecimal = 0;
double binarioEnDecimal = 0;
double binarioanterior = 0;
int i_auxiliar = 0;
for (int i=0; i<n; i++){
int binario= X.nextInterval(0,n)%2;
binarioADecimal=binario* Math.pow(10, -i_auxiliar);
binarioEnDecimal= binarioADecimal+binarioanterior;
binarioanterior=binarioEnDecimal;
if (i_auxiliar==2 && binarioEnDecimal== 0.00){
x0++;}//if1
if (i_auxiliar==2 && binarioEnDecimal== 0.01){
x1++;}//if2
if (i_auxiliar==2 && binarioEnDecimal== 0.10){
x2++;}//if3
if (i_auxiliar==2 && binarioEnDecimal== 0.11){
x3++;}//if4
if (i_auxiliar==2 && binarioEnDecimal== 1.00){
x4++;}//if5
if (i_auxiliar==2 && binarioEnDecimal== 1.01){
x5++;}//if6
if (i_auxiliar==2 && binarioEnDecimal== 1.10){
x6++;}//if7
if (i_auxiliar==2 && binarioEnDecimal== 1.11){
x7++;}//if8
if(i_auxiliar==2){
i_auxiliar=0;
}//reset i_auxiliar
i_auxiliar++;
}//termino de for
double aleatoriedad_de_la_secuencia = ((x0/(n-2))-(1/8))+((x1/(n-2))-(1/8))+((x3/(n-2))-(1/8))+((x4/(n-2))-(1/8))+((x5/(n-2))-(1/8))+((x6/(n-2))-(1/8))+((x7/(n-2))-(1/8));
return aleatoriedad_de_la_secuencia;//return
}//metodo test
public static void main (String[]args){
Random_Ejer_1 X = new Random_Ejer_1(100, 2, 95);
System.out.println(X.test(18));
}//main
}//class
Most of the comments are in spanish, though.
I usually write/program everything in english, as I find it to be a good way to practice my redaction and language skills, but not this time.
Why?
I don't know.
(I'll proooobably do the questions tonight, but I won't upload them until I have the entire questionnaire done. It'd be boring otherwise, since I intend to do some modifications to the program for this particular questionnaire)
EDIT6: I've written about 0.5 of the total number of questions. Way more difficult than I thought it would be. Also, doing some modifications to the Question_O_Matic program, just for my own amusement.
Aaaand working on a program that tells you what input will provide the most random sequence of numbers, for that other program I did (which uses the current date and hour as a seed for the iterations, so it can be a bit predictable unless you give it the appropriate input).
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
Re: The programming thread!
PROGRAMMING!
It is totally awesome.
Tooooootally.
The new algebra, I say.
The new algebra.
It is totally awesome.
Tooooootally.
The new algebra, I say.
The new algebra.
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
Re: The programming thread!
Sometime next week I'll start working on this thing again.
I just haven't had the time.
I just haven't had the time.
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
Re: The programming thread!
Currently working on a program that sends you a funny little message every time a child dies of starvation.
I guess I'll be using 3 or 4 of those 'feel bad for being rich, you bad, bad person' polls and average them.
If I do this right the program should be on the background until someone is statistically likely to have kicked the bucket, at which point a message should pop-out telling you that it's none of your business and that you should feel justified, indeed, proud in your complacency.
It's a good way to practice with graphical interfaces, me thinks.
I guess I'll be using 3 or 4 of those 'feel bad for being rich, you bad, bad person' polls and average them.
If I do this right the program should be on the background until someone is statistically likely to have kicked the bucket, at which point a message should pop-out telling you that it's none of your business and that you should feel justified, indeed, proud in your complacency.
It's a good way to practice with graphical interfaces, me thinks.
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
- DrPepperPro
- Dirty Sennin
- Posts: 2216
- Joined: Mon Aug 20, 2007 5:16 pm
Re: The programming thread!
1 child dies every 5 seconds as a result of hunger - 700 every hour - 16 000 each day - 6 million each year - 60% of all child deaths (2002-2008 estimates).[14][15][16][17][18]
http://en.wikipedia.org/wiki/Child_mortality
Sounds about right. Again, we'll include it in the Berserk releases. Maybe a Berserk themed one? Anyways sounds fun! I'm excited!
http://en.wikipedia.org/wiki/Child_mortality
Sounds about right. Again, we'll include it in the Berserk releases. Maybe a Berserk themed one? Anyways sounds fun! I'm excited!
Re: The programming thread!
Whelp, that's it for the week, fellas!
I'll probably work on the questionnaire this friday/saturday, upload the results the night of the same day.
I wish you all a relatively painless death, at the old age of 70.
Pray that I live forever.
Oh, but first:
(I don't really feel like navigating out of this page, so I'll just post it here)
@Aluja: Kara no Kyouki is not bad, but it doesn't really, well, do anything. With anything.
Everything about it is just so...dull.
Your tastes in anime are downright bizarre, man.
I prescribe you some Tatami Galaxy to cure your extraneous illness.
P.S. I believe the children fatality program is the greatest idea I've ever taken out of a cereal box. Juvenile, but funny. I'll work on it, eventually, then post it here.
Now, if you'll excuse me, I have to go kill the president (allegory for masturbation? Note to self: edit later).
Up, up and away!
I'll probably work on the questionnaire this friday/saturday, upload the results the night of the same day.
I wish you all a relatively painless death, at the old age of 70.
Pray that I live forever.
Oh, but first:
(I don't really feel like navigating out of this page, so I'll just post it here)
@Aluja: Kara no Kyouki is not bad, but it doesn't really, well, do anything. With anything.
Everything about it is just so...dull.
Your tastes in anime are downright bizarre, man.
I prescribe you some Tatami Galaxy to cure your extraneous illness.
P.S. I believe the children fatality program is the greatest idea I've ever taken out of a cereal box. Juvenile, but funny. I'll work on it, eventually, then post it here.
Now, if you'll excuse me, I have to go kill the president (allegory for masturbation? Note to self: edit later).
Up, up and away!
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
Re: The programming thread!
Yeah I'd imagine mine tastes be weird to you, you know, since I'm watching everything with an open mind and all...
This one is probably my fave this generation.
http://anidb.net/perl-bin/animedb.pl?sh ... e&aid=4226
This one is probably my fave this generation.
http://anidb.net/perl-bin/animedb.pl?sh ... e&aid=4226
Re: The programming thread!
Just popped up to post this:
It works fairly well for up to 1000000 values, after which the patterns starts becoming a little too obvious for it to be useful.
It was a real challenge to write, despite its rather simple nature.
I've been very absorbed by the mathematical study of chaos lately.
There's a very interesting article on the subject titled "Omega and why there can be no TOE in mathematics", you guys should google it if you're interested.
I don't want to spoil it, but the ink splash example is fucking awesome.
This program creates, refines and measures the degree of randomness of a sequence of pseudo-random numbers.Code: Select all
import java.util.Date; import IIC1103Package.Usuario; public class Random {static int A; static int B; static int C; int semilla; public Random(int vA, int vB, int vC) {Date now = new Date(); semilla = (int) ((now.getTime())%vC); A = vA; B = vB; C = vC;}//Random constructor public int next(){ semilla = (A*semilla + B)%C; return semilla ;}//next method public int nextInterval(int min, int max) {semilla = (A*semilla + B)%C; return min + semilla%(max-min+1);}//next Interval method public double test (int n){ Random X = new Random(A,B,C); double x0= 0; double x1= 0; double x2= 0; double x3= 0; double x4= 0; double x5= 0; double x6= 0; double x7= 0; int i_auxiliar = 0; int A=-1; int B=-1; int C=-1; int D=-1; int E=-1; for (int i=0; i<n; i++){ if (i_auxiliar == 0){ A=X.nextInterval(0,1); if (i>0){ if (D==0 && E==0 && A==0){ x0++;}//if1 if (D==1 && E==0 && A==0){ x4++;}//if2 if (D==0 && E==1 && A==0){ x2++;}//if3 if (D==1 && E==1 && A==0){ x6++;}//if4 if (D==0 && E==0 && A==1){ x1++;}//if5 if (D==1 && E==0 && A==1){ x5++;}//if6 if (D==0 && E==1 && A==1){ x3++;}//if7 if (D==1 && E==1 && A==1){ x7++;}//if8 } } if (i_auxiliar == 1){ B=X.nextInterval(0,1); if(i>0){ D=B; } if(i>1){ if (E==0 && B==0&& A==0){ x0++;}//if1 if (E==0 && A==0 && B==1){ x1++;}//if2 if (E==1 && A==0 && B==0){ x4++;}//if3 if (E==1 && A==0 && B==1){ x5++;}//if4 if (E==0 && A==1 && B==0){ x2++;}//if5 if (E==0 && A==1 && B==1){ x3++;}//if6 if (E==1 && A==1 && B==0){ x6++;}//if7 if (E==1 && A==1 && B==1){ x7++;}//if8 } } if (i_auxiliar == 2){ C=X.nextInterval(0,1); if (i>0){ E=C;} if (A==0 && B==0 && C==0){ x0++;}//if1 if (A==0 && B==0 && C==1){ x1++;}//if2 if (A==0 && B==1 && C==0){ x2++;}//if3 if (A==0 && B==1 && C==1){ x3++;}//if4 if (A==1 && B==0 && C==0){ x4++;}//if5 if (A==1 && B==0 && C==1){ x5++;}//if6 if (A==1 && B==1 && C==0){ x6++;}//if7 if (A==1 && B==1 && C==1){ x7++;}//if8 i_auxiliar=-1; } i_auxiliar++; }//termino de for double aleatoriedad_de_la_secuencia = Math.abs(((x0/(n-2))-0.125))+Math.abs(((x1/(n-2))-0.125))+Math.abs((x3/(n-2))-0.125)+Math.abs(((x4/(n-2))-0.125))+Math.abs(((x5/(n-2))-0.125))+Math.abs(((x6/(n-2))-0.125))+Math.abs(((x7/(n-2))-0.125)); return aleatoriedad_de_la_secuencia;//return (puesto en 0 por mientras) }//metodo test public void calibrar(int a0, int ai, int b0, int bi, int c0, int ci, int n){ int a = 1; int b = 1; int c = 1; double indice_aleatoriedad_optima = 1; double Valor_Elemento_N_sumatoria = 1; double Sumatoria = 0; //valor = 0 usado por mientras. double promedio_Anterior = 1; //valor = 1 usado por mientras. double promedio= 1; //valor = 1 usado por mientras (va a ser modificado en cada loop, no veo como podria afectar algo). for (int i=a0; i<= ai; i++){ for (int j=b0; j<= bi; j++){ for (int k=c0; k<= ci; k++){ for (int contador_tests=0; contador_tests <100; contador_tests++){ Random X= new Random (i, j, k); Valor_Elemento_N_sumatoria= X.test(n); Sumatoria = Sumatoria+ Valor_Elemento_N_sumatoria; }// loop en el la operacion .test es realizada 100 veces, y los valores obtenidos son sumados. promedio = Sumatoria/100; if (promedio!=0 && promedio<promedio_Anterior){ a=i; b=j; c=k; indice_aleatoriedad_optima = promedio; promedio_Anterior = promedio;//actualiza el valor del indice anterior.}//condicional que determina si el indice de aleatoriedad de la combinacion entregada es mayor que la de la anterior, //y guarda el valor de la combinacion si es asi. } Sumatoria=0; }//termino loop for C, en el que se hacen las operaciones .test con las combinaciones de numeros entregadas por los otros 2 loops. }// termino loop for B, que contiene al loop C. }// termino loop for A, que contiene a los loops B y C. A = a; B = b; C = c; }//cierre de metodo Calibrar public double periodo (){ Random X = new Random(A,B,C); //primero, crear objeto X, que sera usado durante todo el proceso. double sumatoriaTodasLasSemillas= 0; double promedio_total = 0; for (int numeroDeSemilla=1; numeroDeSemilla<= 100; numeroDeSemilla++){ //este for va cambiando el numero de semilla, con 100 en total. int Desplazamiento_hacia_la_derecha = 0; double promedio_semilla = 0; double sumatoria_periodos = 0; double periodo_provisional_semilla= 0; double periodo_definitivo_semilla= 0; int contador_numeros_por_periodo = 0; X.semilla = numeroDeSemilla; for (int semillai=1; semillai<= 100; semillai++){ int ai= X.next(); int lejania_origen = 0; int lejania_origen_anterior = 1; for (int numeroDeNext=0; numeroDeNext<=C+1; numeroDeNext++){ int valores_Sgtes = X.next(); contador_numeros_por_periodo++;//failure waiting to happen if (ai==valores_Sgtes){ lejania_origen = contador_numeros_por_periodo + Desplazamiento_hacia_la_derecha; periodo_provisional_semilla= contador_numeros_por_periodo-1; if (Desplazamiento_hacia_la_derecha==0){ lejania_origen_anterior= lejania_origen; } Desplazamiento_hacia_la_derecha++; for (int Cambio_Valor_ai=0; Cambio_Valor_ai<Desplazamiento_hacia_la_derecha; Cambio_Valor_ai++){ ai= X.next();}//valor ai if (lejania_origen_anterior >=lejania_origen){ periodo_definitivo_semilla = periodo_provisional_semilla; lejania_origen_anterior = lejania_origen; } contador_numeros_por_periodo = 0; }//if ai==valores_Sgtes }//for sumatoria_periodos = sumatoria_periodos + periodo_definitivo_semilla; periodo_definitivo_semilla = 0; Desplazamiento_hacia_la_derecha=0; } promedio_semilla= sumatoria_periodos/100;//ELIMINADO EL ARREGLO TUZON PARA QUE ME SALIERAN VALORES CUERDOS. sumatoriaTodasLasSemillas = promedio_semilla + sumatoriaTodasLasSemillas; promedio_semilla= 0; //System.out.println("Metodo Periodo trabajando, espere..."+ numeroDeSemilla+"% listo"); }//este es el primer parentesis promedio_total = sumatoriaTodasLasSemillas/100; //System.out.print(promedio_total);//osito es determinar la extension de los patrones presentes en la secuencia generada) return promedio_total; } public static void main (String[]args){ Random X= new Random (2,23, 1023); int a0=Usuario.entero ("Ingrese el menor valor de A: "); int ai=Usuario.entero ("Ingrese el mayor valor de A: "); int b0=Usuario.entero ("Ingrese el menor valor de B: "); int bi=Usuario.entero ("Ingrese el mayor valor de B: "); int c0=Usuario.entero ("Ingrese el menor valor de C: "); int ci=Usuario.entero ("Ingrese el mayor valor de C: "); int n=Usuario.entero ("Ingrese el largo de la secuencia deseada "); X.calibrar (a0, ai, b0, bi, c0 , ci , n); X = new Random (A,B,C); X.periodo(); }//main }//class
It works fairly well for up to 1000000 values, after which the patterns starts becoming a little too obvious for it to be useful.
It was a real challenge to write, despite its rather simple nature.
I've been very absorbed by the mathematical study of chaos lately.
There's a very interesting article on the subject titled "Omega and why there can be no TOE in mathematics", you guys should google it if you're interested.
I don't want to spoil it, but the ink splash example is fucking awesome.
One original thought is worth a thousand mindless quotings.
~Diogenes of Sinope
~Diogenes of Sinope
- dialdfordesi
- I live in a giant bucket.
- Posts: 907
- Joined: Sat Jul 02, 2005 9:52 pm
- Location: Bumblefuck, Midwest.
Re: The programming thread!
So this is probably the world's most awesome question: how do I use that code to see the program in action?
Trust me, I'm a doctor!
Re: The programming thread!
Well you'd have a hard time doing that cause Rolos won't stop using that goddamn usario package. But if he wasn't using some random Spanish package, you would just dl the java sdk, copy his code into a text file, save the file as "classname".java (where classname is the name of the class he created) and compile it. I think. I use a Java development program called jGRASP that I can use to compile it so I'm not very familiar with the command line process. Of couse, that's all hypothetical since no one but Rolos can use that GODDAMNED PACKAGE.
- dialdfordesi
- I live in a giant bucket.
- Posts: 907
- Joined: Sat Jul 02, 2005 9:52 pm
- Location: Bumblefuck, Midwest.
Re: The programming thread!
It's depressing that Rolos won't allow anyone else to play with his package
Trust me, I'm a doctor!