[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Lets make a program :^)
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 15
Thread images: 7
File: java.png (16 KB, 259x259) Image search: [Google]
java.png
16 KB, 259x259
>Lets make a java program /g/ (processing so the noobs can join in)
https://codeshare.io/rNQQN
I will run the code in processing 3.0 on twitch,
/rodentsnipe
>>
Print "1488";
>>
for ( i = 0; i > 0; i++){
console.log("Fuck you[i]");
};
>>
>>54470850
>using the smiley with a carat nose
>>
>>54470879
get out mike
>>
File: First compile.png (460 KB, 3496x1088) Image search: [Google]
First compile.png
460 KB, 3496x1088
First program by 4chan
>>
>>54470850
id everything get baleeted?
>>
>java
>being this indian
>>
File: ship.png (18 KB, 133x100) Image search: [Google]
ship.png
18 KB, 133x100
don't know what your ship name is
>>
File: pajeet.jpg (8 KB, 136x198) Image search: [Google]
pajeet.jpg
8 KB, 136x198
pajeet here
>>
File: FB_IMG_1459395868989.jpg (4 KB, 230x219) Image search: [Google]
FB_IMG_1459395868989.jpg
4 KB, 230x219
this is going badly
>>
File: b1 G.png (21 KB, 100x100) Image search: [Google]
b1 G.png
21 KB, 100x100
Alright guys it was fun but its 5am here, heading off.
I'll be back tomorrow with a thread where ill just take requests and change the code/pictures myself so that everyone can participate, and speed up the processing by stopping noobs from fucking it up. adios niggas
>>
I made this short thing and I was wondering:
Is there a way to make the random number different for each time the file runs?
This isn't very interesting if it produces the same results every time.
I thought that generating a random int in a range would work,
but it did not on when I ran it on my machine.

Any ideas?

import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
class Meme{
private int freshness;
private String joke;
public Meme(String m){
this.joke = m;
freshness = 100;
}
public String spout(){
freshness -= ThreadLocalRandom.current().nextInt(0,11);
return this.joke;
}
public String getJoke(){return this.joke;}
public int getFresh(){return this.freshness;}
public boolean equals(Meme m){
if(this.getFresh()==m.getFresh()){return true;}
else{return false;}
}
public int compareTo(Meme m){return this.getFresh()-m.getFresh();}
}
class MemeComparitor implements Comparator<Meme>{
@Override
public int compare(Meme a, Meme b){
return a.getFresh()-b.getFresh();
}
}
public class MemeMaster{
public static void main(String[] args){
Meme[] memes = new Meme[args.length];
for(int i=0;i<args.length;i++){
memes[i] = new Meme(args[i]);
}
for(int i=0;i<args.length*8;i++){
System.out.println((memes[ThreadLocalRandom.current().nextInt(0,memes.length)]).spout());
}
Arrays.sort(memes,new MemeComparitor());
System.out.println("\nAlright, lets see what memes are on top today!"); // :")
for(int i1=1,i2=memes.length-1;i1<=memes.length;i1++,i2--){
System.out.printf("%d: %s\n",i1,(memes[i2]).getJoke());
}
}
}
>>
File: JMeme.jpg (54 KB, 617x530) Image search: [Google]
JMeme.jpg
54 KB, 617x530
>>54470850

//we create a factory for factories, so we can create more abstract factories
// todo: put this into various UML charts
public abstract class AbstractFactoryFactory {
abstract abstractFactory createAbstractFactory(int… array);
}

// a meme example to demonstrate the awsomeness of inheritance
puclic class memeExampleDog extends memeExmapleAnimal{
@override
puclic void makeSound(){
System.out.println("Woof! I'm a meme.")
}
}

//test factory factory factory
public class TestFactoryFactoryFactoryPattern {
// do some testing here
try{
myMemeExampleDog = new emeExampleDog("unexpected arg");
} catch (RuntimeException e) {
// uhm... well, let' print the stack trace
e.printStackTrace(System.out);
// done
} finally {
System.out.println("You, sir, are an asshat.")
}
}

>>
>>54472928
>using the smiley with a quote nose
Thread replies: 15
Thread images: 7

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.