Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

branch test, erster commit #35

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
468 changes: 468 additions & 0 deletions .idea/dbnavigator.xml

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 23 additions & 3 deletions clean-code-challanges/src/main/java/Acronym.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,36 @@
*
* Techies love their TLA (Three Letter Acronyms)!
*
* Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).
* Help generate some jargon by writing a program that converts a long name like
* Portable Network Graphics to its acronym (PNG).
*/
class Acronym {

Acronym(String phrase) {
String phrase;

Acronym(String phrase) {
this.phrase = phrase;
}

String get() {
return null;
String acronym = "";

char[] arrChar = new char[phrase.length()];

for (int i = 0; i < phrase.length(); i++) {
arrChar[i] = phrase.charAt(i);
}

acronym += arrChar[0];

for(int i = 1; i<phrase.length();i++){
if((phrase.substring(i-1, i).equals(" ")&&!phrase.substring(i).equals("_"))||(phrase.substring(i-1, i).equals("-")&&!phrase.substring(i).equals(" "))
||(phrase.substring(i-1, i).equals("-")&&!phrase.substring(i).equals(" "))){
acronym += Character.toUpperCase(phrase.charAt(i));
}
}

return acronym;
}

}
18 changes: 16 additions & 2 deletions clean-code-challanges/src/main/java/Anagram.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import java.util.ArrayList;
import java.util.List;

/**
* Given a word and a list of possible anagrams, select the correct sublist.
*
* Given "listen" and a list of candidates like "enlists" "google" "inlets" "banana" the program should return a list containing "inlets".
* Given "listen" and a list of candidates like "enlists" "google" "inlets" "banana" the program
* should return a list containing "inlets".
*/
public class Anagram {

public Anagram(String word) {
public String word;

public Anagram(String word) {
this.word = word;
}



public List<String> match(List<String> candidates) {

ArrayList<String> liste1 = new ArrayList<String>();
liste1.add("enlist");
liste1.add("google");
liste1.add("inlets");
liste1.add("banana");


return null;
}
}
54 changes: 51 additions & 3 deletions clean-code-challanges/src/main/java/IsogramChecker.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,58 @@
*
* The word isograms, however, is not an isogram, because the s repeats.
*/
class IsogramChecker {
public class IsogramChecker {

boolean isIsogram(String phrase) {
throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
// String phrase;
////
// IsogramChecker(String phrase){
// this.phrase = phrase;
// }

public boolean isIsogram(String phrase) {//static
//throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
String phrase1 = phrase.toLowerCase();
boolean isIsogram = false;
//int hilfszahl = 0;
int counter = 0;
char derBuchstabe = ' ';

//td lowercase phrase
//todo wenn grösser zwei, nur, wenn es eine leertaste oder ein bindestrich ist

String phraseCopy = phrase1;
for(int i = 0; i<phrase1.length();i++){
int hilfszahl = 0;

for(int j = 0; j<phraseCopy.length();j++){
if(phrase1.charAt(i)==phraseCopy.charAt(j)){
hilfszahl++;
}
}

if (hilfszahl > counter) {
counter = hilfszahl;
//derBuchstabe = derBuchstabe+phrase.charAt(i);
// System.out.println("derBuchstabdfffe: " + phrase.charAt(i));
derBuchstabe = phrase1.charAt(i);
}
}

if(derBuchstabe=='-'&&counter>1 || (derBuchstabe==' '&&counter>1) || !(counter>1)){
isIsogram=true;
}else{
isIsogram = false;
}
// if(counter>1 || !(derBuchstabe=='-'&&counter>1)){//(Character.isLetter(derBuchstabe))){// Character.isDefined(derBuchstabe)=='-'){//|| (counter>1 && derBuchstabe='-')){
// isIsogram = false;
// }else{
// isIsogram = true;
// }

// System.out.println("derBuchstabe: " + derBuchstabe);
// System.out.println("counter: "+counter);

return isIsogram;
}

}
55 changes: 55 additions & 0 deletions clean-code-challanges/src/main/java/MainAcronym.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import java.util.ArrayList;

/**
* @author - John Schmidt
* 19.09.2022, 00:44
*/
public class MainAcronym {

public static void main(String[] args) {
String phrase = "The Road _Not* Taken";

System.out.println(get(phrase));
}


static String get(String phrase) {
String acronym = "";
// phrase.split(" ");

System.out.println("split: "+phrase);

char[] arrChar = new char[phrase.length()];

for (int i = 0; i < phrase.length(); i++) {
arrChar[i] = phrase.charAt(i);
}

acronym += arrChar[0];

//ArrayList<String> arr = new ArrayList<>();
String[] arr1= phrase.split(" ");
System.out.println("l: "+arr1.length);
for(int i = 0; i<arr1.length;i++){
//arr[i] = phrase.charAt(i);
System.out.println(arr1[i]);
}
for(int i = 1; i<phrase.length();i++){
if((phrase.substring(i-1, i).equals(" ")&&phrase.substring(i).equals("_"))||phrase.substring(i-1, i).equals("-")&&!phrase.substring(i).equals("_")&&!phrase.substring(i-1,i).equals("_")){
//arrChar[i] = Character.toUpperCase(phrase.charAt(i));
acronym += Character.toUpperCase(phrase.charAt(i));
//arr.add(phrase.charAt(i));//i) = Character.toUpperCase(phrase.charAt(i));
}
}


for (int i = 0; i < arrChar.length; i++) {
//.out.print(arr[i]);
//acronym += arr.get(i);//[i];
//acronym += arrChar[i];
}

return acronym;
}

}
42 changes: 42 additions & 0 deletions clean-code-challanges/src/main/java/MainAnagram.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import java.util.ArrayList;
import java.util.List;

/**
* @author - John Schmidt
* 18.09.2022, 14:18
*/
public class MainAnagram {
public static void main(String[] args) {

ArrayList<String> liste1 = new ArrayList<String>();
liste1.add("enlist");
liste1.add("google");
liste1.add("inlets");
liste1.add("banana");

System.out.println(match(liste1));

}

public String alphabet(List<String> candidates){
String alphabet = "abcdefghijklnmopqrstuvwxyz";


return null;
}

public static List<String> match(List<String> candidates) {

System.out.println("In übergebener Liste enthalten: ");
for(int i = 0; i<candidates.size();i++){
System.out.println(candidates.get(i));
}

ArrayList<String> list2 = new ArrayList<String>();
list2.add("g");


return list2;
}

}
59 changes: 59 additions & 0 deletions clean-code-challanges/src/main/java/MainIsogramm.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @author - John Schmidt
* 25.09.2022, 23:52
*/
public class MainIsogramm {
public static void main(String[] args) {

String phrase = "sixyearoldd";

System.out.println(findIsogramm(phrase));

}

public static boolean findIsogramm(String phrase){
//String word = phrase + " hello";-
String phrase1 = phrase.toLowerCase();
System.out.println(phrase1);
boolean isIsogram = false;
//int hilfszahl = 0;
int counter = 0;
char derBuchstabe = ' ';

String phraseCopy = phrase1;
for(int i = 0; i<phrase1.length();i++){
int hilfszahl = 0;

for(int j = 0; j<phraseCopy.length();j++){
if(phrase1.charAt(i)==phraseCopy.charAt(j)){
hilfszahl++;
}
}

if (hilfszahl > counter) {
counter = hilfszahl;
//derBuchstabe = derBuchstabe+phrase.charAt(i);
// System.out.println("derBuchstabdfffe: " + phrase.charAt(i));
derBuchstabe = phrase1.charAt(i);
}
}

if(derBuchstabe=='-'&&counter>1 || !(counter>1)){
isIsogram=true;
}else{
isIsogram = false;
}

// if(counter>1|| (derBuchstabe=='-'&&counter>1)){
// isIsogram = false;
// }else{
// isIsogram = true;
// }

System.out.println("derBuchstabe: " + derBuchstabe);
System.out.println("counter: "+counter);

return isIsogram;
}

}
Loading