asciimage fehler

0 views
Skip to first unread message

Murat KOZAN

unread,
Apr 12, 2011, 3:08:52 PM4/12/11
to javacoder_ss11
dostum senin ensonki yaptigini hic degistirmden diger resimlere
denedim busefer onlarada fehler veriyor.



class AsciiImage{


int bildHohe=0;
int bildBreite=0;
String bild= "";



boolean ok= false;
public boolean addLine(String zeile){

if (bildHohe == 0){
if(zeile.length() == 0){ // wenn keinezeichen in erstezeile steht

ok = false;
}else{
bildBreite = zeile.length();
}
}
else if(bildBreite != zeile.length()){ //zeilenlaenge kontroll

ok = false;
}else{

bild += zeile;
bildHohe++;

ok = true;
}
return ok;
}
public int getWidth(){

return bildBreite;
}
public int getHeight(){

return bildHohe;
}

public String toString(){

String temp = ""; //von bild zeile speichern
String richtigesBild = "";


for(int i= 0; i < bild.length() ; i += bildBreite)
{

temp = bild.substring(i, i+bildBreite);

richtigesBild += temp + "\n";
}

return richtigesBild;
}

public int getUniqueChars(){
boolean kontrol = true;
String k="";
int zeichenAnzahl = 0;
for(int i=0; i<bild.length(); i++){

char c = bild.charAt(i);
String s= Character.toString(c);
kontrol = k.contains(s);

if(kontrol){
//zeichen existiert schon
}else
k+=s;
}

return k.length();
}

public void flipV(){ //bild wird
String temp = ""; //von bild zeile speichern
String richtigesBild = "";

for(int i= bild.length(); i > 0 ; i -= bildBreite)// bild von letzte
zeile gelesen
{

temp = bild.substring(i-bildBreite,i ); //auf temp gespeichert

richtigesBild += temp + "\n"; // bild von temp mit zeilen als
ganze in variable richtigesbild gespeichert
}
System.out.println(richtigesBild+bildBreite+" "+bildHohe);

}

public void transpose(){


}
}

________________________________________________________--

import java.util.Scanner;
class AsciiShop{



public static void main (String [] args){
Scanner sc = new Scanner(System.in);

AsciiImage bild1 = new AsciiImage();

int rp=0; //read parameter
String r=""; //wort read
String zeile = "";
String befehl ="";
boolean ok = true; //fur fehler behandlung

r+=sc.next(); //read speichern
if(r.equals("read")){
if(sc.hasNextInt()){ //wenn eine zahl kommt
rp=sc.nextInt(); //read parameter speichern

while(sc.hasNext() && bild1.getHeight()<rp){ //bild speichern

zeile = sc.nextLine();
ok = bild1.addLine(zeile);
}
}
else
System.out.println(" read hat kein zahl ");

}

if(sc.hasNext()){ //befehl verwaltung
befehl = sc.next();

if(befehl.equals("transpose")){ //befehl vegleichen
bild1.transpose();
}
else if(befehl.equals("flip-v")){
bild1.flipV();
}else if(befehl.equals("uniqueChars")){
System.out.print(bild1.getUniqueChars()+"\n"+bild1.toString()
+"\n"+bild1.getWidth()+" "+bild1.getHeight());

}else
System.out.println("befehl falsch befehl ist : "+befehl);

}
else if ( ok ) {
System.out.println(bild1.toString()+bild1.getWidth()+"
"+bild1.getHeight()); //bild ausgeben
}
else if ( !ok ) {
System.out.println("FEHLER");
}
}

}

Burhan Göksu

unread,
Apr 12, 2011, 3:11:33 PM4/12/11
to javacod...@googlegroups.com
@murat
dostum, bug�n tuncayin yazdigi gibi, bize hata olarak tam ne yazdiginida
yazarsan, sana daha cabuk yardim edebiliriz...

kib burhan

> while(sc.hasNext()&& bild1.getHeight()<rp){ //bild speichern

Murat Kozan

unread,
Apr 12, 2011, 3:31:22 PM4/12/11
to javacod...@googlegroups.com
hata olarak

FEHLER


yaziyor, bu hatayi Main methodunun icinde en asagida belirlemistik

if (!ok)  diye basliyor.

Murat



> Date: Tue, 12 Apr 2011 21:11:33 +0200
> From: burhan...@gmail.com
> To: javacod...@googlegroups.com
> Subject: Re: asciimage fehler
>
> @murat
> dostum, bugün tuncayin yazdigi gibi, bize hata olarak tam ne yazdiginida
Reply all
Reply to author
Forward
0 new messages