import junit.framework.TestCase;
public class TestHomework extends TestCase {
public void testGIGO() {
String input = "3b1w3b";
String expectedOutput = "BBBWBBB";
HomeworkWorker worker = new HomeworkWorker();
assertEquals("you are not clever enough to do this yourself", expectedOutput, worker.doHomework(input));
}
class HomeworkWorker {
public String doHomework(String input) {
return "BBBWBBB";
}
}
}
Le Bar Verte - hooray
enjoy
No one here will do something like that for you!! I will not tell you that it is easy because maybe you just only started programming. However I will give you some sugestions!!
1. Pencil and Paper are your friends! Try writing on a peace of paper what you want to do in normal english. A paragraph will be more then enough, then try to change that in a set of steps!
2. You will realize that you need some classes already in Java. Did your tutor already tell you about them? try searching in your notes!
3. Try something out first. Come here, show us what you tried out, and someone will help you!
Remeber that for some people here that problem can be solved in a minute max! they do not tell you the answer because they want you to learn something!
Regards,
Sim085
Are you guys abusing the newbies again? Didn't UJ tell you that's not allowed in here? Hmm?
@OP: Here you go, hand this in to your teacher:
public class Test {
static java.io.PrintStream o = java.lang.System.out;
public static void main(String[] args) {
String s = "3b1w3b";
char[] cs = s.toLowerCase().toCharArray();
for(int i=0x0, j=0x0; i < cs.length-0x1; i+=0x2, j=0x0) {
while(j++ < (int)(cs[i]-0x30)){ o.print((char)(cs[i+0x1]-0x20));}
}
}
}
> Are you guys abusing the newbies again? Didn't UJ
> tell you that's not allowed in here? Hmm?
> @OP: Here you go, hand this in to your teacher:
> public class Test {
> static java.io.PrintStream o =
> java.lang.System.out;
>public static void main(String[] args) {
>String s = "3b1w3b";
>char[] cs = s.toLowerCase().toCharArray();
> for(int i=0x0, j=0x0; i < cs.length-0x1; i+=0x2,
> j=0x0) {
> while(j++ < (int)(cs[i]-0x30)){
> o.print((char)(cs[i+0x1]-0x20));}
>}
> }
thanks prometheuzz for sharing your knowledge , this was a big help to me
> public class Test {
> static java.io.PrintStream o =
> java.lang.System.out;
>public static void main(String[] args) {
>String s = "3b1w3b";
>char[] cs = s.toLowerCase().toCharArray();
> for(int i=0x0, j=0x0; i < cs.length-0x1; i+=0x2,
> j=0x0) {
> while(j++ < (int)(cs[i]-0x30)){
> o.print((char)(cs[i+0x1]-0x20));}
>}
> }
Oh great, so "10b" won't print as "bbbbbbbbbb"? While I'm at it, should
"30" print as "000" or generate an exception? and what about "321",
should there be 32 "1"s, 3 "2"s or what? I demand correct, non-ambiguous
specifications! Anything else is *bogus*! Wraaahhhhgggrrr!
sorry ... I'll have a drink and calm down now; promised ;-)
kind regards,
Jos (< easy going, easy now, easy)
import java.io.*;
public class Test {
static java.io.PrintStream o = java.lang.System.out;
public static void main(String[] args)throws Exception {
BufferedReader BR = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter plot for printing: ");
String s = BR.readLine();
char[] cs = s.toLowerCase().toCharArray();
for(int i=0, j=0; i < cs.length-0x1; i+=0x2, j=0)
{
while(j++ < (int)(cs-0x30))
{
o.print((char)(cs[i+0x1]-0x20));
}
}
}
}
I tried changeing it to this so I can enter my own string, but I want to change it some more so that it can enter multiple input separated by space, so that it can form a sort of picture line by line. I tried using tolkenizer but I get errors. I dont know how to use tolkenizer properly can anyone please TEACH. you dont have to tell how or give me the code if you dont want to. yes I know Im a noob and I dont know java as good as everyone here, If everyone thinks I don't deserve help then DON'T help, I'm just trying to learn programming
No no, never use keyboard input! All real guys use arguments!
Sorry, prometheuzz, I changed formatting...
public class Test
{
static java.io.PrintStream o = java.lang.System.out;
public static void main( String[] args )
{
for( int k = 0; k < args.length; k++, o.println("") )
{
char[] cs = args[k].toLowerCase().toCharArray();
for(int i=0x0, j=0x0; i < cs.length-0x1; i+=0x2, j=0x0)
{
while(j++<(int)(cs[i]-0x30)){o.print((char)(cs[i+0x1]-0x20));}
}
}
}
}
BTW this code accepts strings like "10a5b" but I'm not sure this is correct behavior.
importjava.util.regex.*;
public class lox { static
java.io.PrintStreamo=
java.lang.System.out;static
Pattern p =Pattern.compile(
"([1-9]+[0-9]*)([a-z])" ) ;
public static void main (
String[]args){for(int j=0;j
<args.length;j++,o.println(
"" ) ){Matcher m=p.matcher(
args[j]) ; while(m.find()){
int c = Integer.parseInt(m.
group(1));String s=m.group(
2).toUpperCase();for(int i=
0;i<c;i++)o . print(s);}}}}
>