fixed bugs in TextOutput.java
This commit is contained in:
		
							parent
							
								
									94fa99d5b2
								
							
						
					
					
						commit
						bbc5a07f53
					
				| 
						 | 
				
			
			@ -40,8 +40,8 @@ public class TextOutput {
 | 
			
		|||
     * @param text the ArrayList which is used for the output.
 | 
			
		||||
     */
 | 
			
		||||
    private void toFormat(ArrayList<String> text) {
 | 
			
		||||
        int currentLength = 0;
 | 
			
		||||
        for (String paragraph : text) {
 | 
			
		||||
            int currentLength = 0;
 | 
			
		||||
            String[] words = paragraph.split(" ");
 | 
			
		||||
            int lastWordNumber = words.length;
 | 
			
		||||
            int currentWordNumber = 0;
 | 
			
		||||
| 
						 | 
				
			
			@ -49,24 +49,21 @@ public class TextOutput {
 | 
			
		|||
                currentWordNumber++;
 | 
			
		||||
                if (word.length()<= columnWidth - currentLength) {
 | 
			
		||||
                    System.out.print(word);
 | 
			
		||||
                    if (!(lastWordNumber == currentWordNumber)) {
 | 
			
		||||
                        System.out.print(" ");
 | 
			
		||||
                        currentLength = currentLength + word.length() + 1;
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    if(currentWordNumber != 1) {
 | 
			
		||||
                        System.out.println();
 | 
			
		||||
                        }
 | 
			
		||||
                        currentLength = 0;
 | 
			
		||||
                    }
 | 
			
		||||
                    System.out.print(word);
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
                if(!(currentWordNumber == lastWordNumber)) {
 | 
			
		||||
                    System.out.print(" ");
 | 
			
		||||
                    currentLength = currentLength + word.length() + 1;
 | 
			
		||||
                }
 | 
			
		||||
                else {
 | 
			
		||||
                    System.out.println();
 | 
			
		||||
                    System.out.print(word);
 | 
			
		||||
                    if(!(currentWordNumber == lastWordNumber)) {
 | 
			
		||||
                        System.out.print(" ");
 | 
			
		||||
                        currentLength = word.length() + 1;
 | 
			
		||||
                    }
 | 
			
		||||
                    else {
 | 
			
		||||
                        System.out.println();
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue