Tobe

TOBE
 

Downloads:
tobe.exe (pseudoexe - 11KB)

Source:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ToBe

{

public partial class Form1 : Form
{

string s1 = "";//Eingabestring
string sum = "";//String mit eingefügten 'b's
public Form1()
{

InitializeComponent();

}

private void btn_end_Click(object sender, EventArgs e)
{

this.Close();

}
/***** Mit elementaren Stringops/ Ohne Majuskelbehandlung *****/
private void btn_tobe_Click(object sender, EventArgs e)
{

s1 = txt_ein.Text;

/***** Schleife über den Eingabestring *****/
for (int i = 0; i < s1.Length; i++)
{

/***** Vokalsuche *****/
if(Char.ToLower(s1[i])=='a'||Char.ToLower(s1[i])=='e'||Char.ToLower(s1[i])=='i'||Char.ToLower(s1[i])=='o'||Char.ToLower(s1[i])=='u') {

/***** Einfügen von "b" und Wiederholen des Vokals,Anfügen an das aktuelle Ergebnis *****/

sum += s1.Substring(0, i + 1) + "b" + s1.Substring(i,1);

/***** Unbearbeiteter Rest *****/
s1 = s1.Substring(i + 1, s1.Length - (i + 1));
i = -1;
//...Neuinitialisierung der for-Schleife

}

}
/***** Vokalloser Rest wir angefügt *****/
sum += s1;
txt_aus.Text = sum;

}
/***** Mit Stringops/ Ohne Majuskelbehandlung *****/
private void btn_tobe2_Click(object sender, EventArgs e)
{

s1 = txt_ein.Text;
s1 = s1.Replace("a", "aba");
s1 = s1.Replace("e", "ebe");
s1 = s1.Replace("i", "ibi");
s1 = s1.Replace("o", "obo");
s1 = s1.Replace("u", "ubu");
txt_aus.Text = s1;

}
/***** Elegant, mit Stringops/ Mit Majuskelbehandlung *****/
private void btn_tobe3_Click(object sender, EventArgs e)
{

string[] vok = new string[] { "a", "e", "i", "o", "u", "A", "E", "I", "O", "U" };
string[] bvok=new string[] {"aba","ebe","ibi","obo","ubu","Aba","Ebe","Ibi","Obo","Ubu"};
s1 = txt_ein.Text;

for (int i = 0; i < vok.Length; i++)
{

s1 = s1.Replace(vok[i], bvok[i]);

}
txt_aus.Text = s1;

}

}

}

<<zurück>>