Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Homework

Name: Anonymous 2007-04-09 13:17 ID:HpLdMw06

Ok /prog/, this is very simple.

You're going to do my programming homework. Because want you to.

This is very simple... Work + No Spare Time = No Homework Done

So here's the deal: I supply to you my Java Homeworks and you'll do it.
If you're unable to do it, feel free to post whatever you like.
If you're a fucking coding god, you will post your ultimate solution, and face the criticism from other coding gods, including moot.

Cruel Leonidas demanded that you stand. I require only that you kneel.

Name: Anonymous 2007-04-11 9:59 ID:iVmnI21Z

Run it with a filename as the command line argument.
import java.io.*;
import java.util.*;
public class YourHomework {
    private static final boolean flags[][]={
        {true,true,true,false,true,true,true},
        {false,false,true,false,false,true,false},
        {true,false,true,true,true,false,true},
        {true,false,true,true,false,true,true},
        {false,true,true,true,false,true,false},
        {true,true,false,true,false,true,true},
        {true,true,false,true,true,true,true},
        {true,false,true,false,false,true,false},
        {true,true,true,true,true,true,true},
        {true,true,true,true,false,true,true}
    };
    private static void printDigitLine(int n,int size,int line) {
        char l=' ',c=' ',r=' ';
        if (line==0) {
            if (flags[n][0]) c='-';
        } else if (line<=size) {
            if (flags[n][1]) l='|';
            if (flags[n][2]) r='|';
        } else if (line==size+1) {
            if (flags[n][3]) c='-';
        } else if (line<=2*size+1) {
            if (flags[n][4]) l='|';
            if (flags[n][5]) r='|';
        } else if (flags[n][6]) c='-';
        System.out.print(l);
        for (int i=0;i<size;i++) System.out.print(c);
        System.out.print(r);
    }
    public static void main(String args[]) {
        if (args.length==0) {
            System.out.println("must be run with a filename argument");
            return;
        }
        try {
            BufferedReader in=new BufferedReader(new FileReader(args[0]));
            String l;
            StringTokenizer t;
            int size;
            String digits;
            int maxperline;
            int lines;
            int bound;
            while ((l=in.readLine())!=null) {
                t=new StringTokenizer(l);
                size=Integer.parseInt(t.nextToken());
                digits=t.nextToken();
                maxperline=81/(size+3);
                lines=digits.length()/maxperline+1;
                for (int i=0;i<lines;i++) {
                    for (int j=0;j<2*size+3;j++) {
                        bound=Math.min(digits.length(),(i+1)*maxperline);
                        for (int k=i*maxperline;k<bound;k++) {
                            printDigitLine(digits.charAt(k)-'0',size,j);
                            if (k<bound-1) System.out.print(' ');
                        }
                        System.out.print('\n');
                    }
                    System.out.print('\n');
                }
            }
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
    }
}

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List