From 0661a987edcfd0d68425312244b45c1cc914a0b5 Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Fri, 5 May 2017 20:08:04 +0200 Subject: [PATCH] Performed step in Demo coding. --- src/fr/devinsy/util/strings/demo/Demo.java | 83 +++++++++++++++++----- 1 file changed, 64 insertions(+), 19 deletions(-) diff --git a/src/fr/devinsy/util/strings/demo/Demo.java b/src/fr/devinsy/util/strings/demo/Demo.java index 8136752..b7df340 100644 --- a/src/fr/devinsy/util/strings/demo/Demo.java +++ b/src/fr/devinsy/util/strings/demo/Demo.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Date; import fr.devinsy.util.strings.StringList; +import fr.devinsy.util.strings.StringsUtils; /** * The Class Demo. @@ -58,26 +59,70 @@ public class Demo strings.appendln("========== DEMO #2;"); strings.appendln(); strings.appendln("Easy to concatenate different types."); - strings.append("Boolean: ").append(true).append(" ").appendln(new Boolean(false)); - strings.append("Char: ").append('e').append(" ").appendln(new Character('e')); - strings.append("Byte : ").append((byte) 5).append(" ").appendln(new Byte((byte) 5)); - strings.append("Short: ").append((short) 55).append(" ").appendln(new Short((short) 55)); - strings.append("Integer: ").append(555).append(" ").appendln(new Integer(555)); - strings.append("Long: ").append(5555L).append(" ").appendln(new Long(5555)); - strings.append("Float: ").append((float) 5555.5).append(" ").appendln(new Float(5555.5)); - strings.append("Double: ").append(5555.55).append(" ").appendln(new Double(5555.55)); - strings.append("String: ").append("abcde").append(" ").appendln(new String("edcba")); - strings.append("Object: ").appendln(new Date()); - strings.append("Array of boolean:").appendln(new boolean[] { true, false, true }); - strings.append("Array of char: ").appendln(new char[] { 'a', 'b', 'c' }); - strings.append("Array of byte: ").appendln(new byte[] { (byte) 1, (byte) 2, (byte) 3 }); - strings.append("Array of short: ").appendln(new short[] { (short) 1, (short) 2, (short) 3 }); - strings.append("Array of string: ").appendln(new String[] { "a", "b", "c" }); + strings.append("Boolean: ").append(true).append(" ").appendln(new Boolean(false)); + strings.append("Char: ").append('e').append(" ").appendln(new Character('e')); + strings.append("Byte : ").append((byte) 5).append(" ").appendln(new Byte((byte) 5)); + strings.append("Short: ").append((short) 55).append(" ").appendln(new Short((short) 55)); + strings.append("Integer: ").append(555).append(" ").appendln(new Integer(555)); + strings.append("Long: ").append(5555L).append(" ").appendln(new Long(5555)); + strings.append("Float: ").append((float) 5555.5).append(" ").appendln(new Float(5555.5)); + strings.append("Double: ").append(5555.55).append(" ").appendln(new Double(5555.55)); + strings.append("String: ").append("abcde").append(" ").appendln(new String("abcde")); + strings.append("Object: ").appendln(new Date()); + strings.append("Array of booleans: ").appendln(StringsUtils.toStringList(new boolean[] { true, false, true })); + strings.append("Array of chars: ").appendln(StringsUtils.toStringList(new char[] { 'a', 'b', 'c' })); + strings.append("Array of bytes: ").appendln(StringsUtils.toStringList(new byte[] { (byte) 1, (byte) 2, (byte) 3 })); + strings.append("Array of shorts: ").appendln(StringsUtils.toStringList(new short[] { (short) 1, (short) 2, (short) 3 })); + strings.append("Array of longs: ").appendln(StringsUtils.toStringList(new long[] { 1L, 2L, 3L })); + strings.append("Array of strings(1): ").appendln(new String[] { "ab", "cd", "e" }); + strings.append("Array of strings(2): ").appendln("ab", "cd", "e"); + strings.append("Array of objects: ").appendln(new Object[] { "ab", "cd", "e" }); ArrayList buffer = new ArrayList(); - buffer.add("aa"); - buffer.add("bb"); - buffer.add("cc"); - strings.append("Collections: ").appendln(buffer); + buffer.add("ab"); + buffer.add("cd"); + buffer.add("e"); + strings.append("Collections: ").appendln(buffer); + + System.out.println(strings.toString()); + } + + // #3 + { + StringList strings = new StringList(); + + strings.appendln("========== DEMO #3;"); + strings.appendln(); + strings.appendln("Useful and easy methods."); + StringList list = new StringList("red", "blue", "green"); + strings.append("Format(1): ").appendln(list.toStringWithBracket()); + strings.append("Format(2): ").appendln(list.toStringWithBrackets()); + strings.append("Format(3): ").appendln(list.toStringWithCommas()); + strings.append("Format(4): ").appendln(list.toStringWithFrenchCommas()); + strings.append("RemoveLast: ").appendln(list.removeLast().toStringWithFrenchCommas()); + + System.out.println(strings.toString()); + } + + // #4 + { + StringList strings = new StringList(); + + strings.appendln("========== DEMO #4;"); + strings.appendln(); + strings.appendln("Advanced features."); + strings.append("Boolean: ").append(true).append(" ").appendln(new Boolean(false)); + + System.out.println(strings.toString()); + } + + // #5 + { + StringList strings = new StringList(); + + strings.appendln("========== DEMO #5;"); + strings.appendln(); + strings.appendln("Funny features."); + strings.append("Boolean: ").append(true).append(" ").appendln(new Boolean(false)); System.out.println(strings.toString()); }