Hi all im new in java (1 month). I am reading a book and wanted to make my learning easy by making a help menu, but there is a problem i cant solve on my own.
p.s. sorry about the language its Latvian, so i could understand it more easy.
class Help { void helpon (int what) { switch(what) { case '1' : System.out.println("\"if\" veido: "); System.out.println("if(nosacijums)kas notiek; "); System.out.println("\telse kas notiek; \n"); break; case '2' : System.out.println("\"switch\" veido : "); System.out.println("switch (nemainigais) { "); System.out.println("\tcase 'attiecigais nosaukums' : un ko dara; "); System.out.println("break; lai visu partrauktu\n"); break; case '3' : System.out.println("\"for\" veido: "); System.out.println("for(kur sakas; kur beidzas; formula"); System.out.println("bet ir ari protams daudz dazadu veidu, ka manipulet ar \"for\" \n"); break; case '4' : System.out.println("\"while\" veido : "); System.out.println("while(nosacijums) ko dara; "); System.out.println("un dara tik ilgi, lidz paradas \"false\" pie izpildes \n"); break; case '5' : System.out.println("\"do-while\" veido : "); System.out.println("do { nosacijums ko dara; "); System.out.println("\twhile cik ilgi dara\n "); break; case '6' : System.out.println("\"break\" veido : "); System.out.println("... kods (kas ir aizverts(logiski pabeigts)) break; vai break label; "); System.out.println("pec break atlikuso koda dalu(kas atrodas taja pasa bloka) vairs neizpilda\n"); case '7' : System.out.println("\"continue\" veido : "); System.out.println("nosacijums continue;"); System.out.println("pec continue izpildas tikai nodefinetas formulas vai ari neizpildas nenodefinetas\n"); } System.out.println(); } void showmenu() { System.out.println("Sis ir palidzibas logs: "); System.out.println("1. Lai iegutu info par \"if\" spied : 1 "); System.out.println("2. Lai iegutu info par \"switch\" spied : 2 "); System.out.println("3. Lai iegutu info par \"for\" spied : 3 "); System.out.println("4. Lai iegutu info par \"while\" spied : 4 "); System.out.println("5. Lai iegutu info par \"do-while\" spied : 5 "); System.out.println("6. Lai iegutu info par \"break\" spied : 6 "); System.out.println("7. Lai iegutu info par \"continue\" spied : 7\n"); System.out.println("spied 'q' lai izietu"); } boolean isvalid(int a) { if(a < '1' | a > '7'& a != 'q') return false; else return true; } } class HelpClassDemo { public static void main(String args []) throws java.io.IOException{ char b; Help hlpobj = new Help(); for( ; ; ) { do{ hlpobj.showmenu(); do{ b = (char) System.read.in(); } while(b == '\n' | b == '\r'); }while( !hlpobj.isvalid(b) ); if(b == 'q') break; System.out.println("\n"); hlpobj.helpon(b); } } }