From acc10ee2f877f2e1352b408d4ea9a231e86e459a Mon Sep 17 00:00:00 2001 From: HesamAlikhani Date: Fri, 22 Mar 2024 13:10:15 +0330 Subject: [PATCH] files --- .idea/.gitignore | 3 + .idea/Functions-Introduction.iml | 9 + .idea/misc.xml | 6 + .idea/modules.xml | 8 + .idea/vcs.xml | 7 + Answers/40230112094/.gitignore | 29 +++ Answers/40230112094/.idea/misc.xml | 6 + Answers/40230112094/.idea/modules.xml | 8 + Answers/40230112094/.idea/vcs.xml | 6 + Answers/40230112094/.idea/workspace.xml | 78 ++++++++ Answers/40230112094/Functions.iml | 11 ++ Answers/40230112094/src/Functions.java | 242 ++++++++++++++++++++++++ Answers/40230112094/src/Main.java | 131 +++++++++++++ 13 files changed, 544 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/Functions-Introduction.iml create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 Answers/40230112094/.gitignore create mode 100644 Answers/40230112094/.idea/misc.xml create mode 100644 Answers/40230112094/.idea/modules.xml create mode 100644 Answers/40230112094/.idea/vcs.xml create mode 100644 Answers/40230112094/.idea/workspace.xml create mode 100644 Answers/40230112094/Functions.iml create mode 100644 Answers/40230112094/src/Functions.java create mode 100644 Answers/40230112094/src/Main.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/.idea/Functions-Introduction.iml b/.idea/Functions-Introduction.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/Functions-Introduction.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..69ace3f --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..95e372b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..0ae64b9 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/Answers/40230112094/.gitignore b/Answers/40230112094/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/Answers/40230112094/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/Answers/40230112094/.idea/misc.xml b/Answers/40230112094/.idea/misc.xml new file mode 100644 index 0000000..69ace3f --- /dev/null +++ b/Answers/40230112094/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112094/.idea/modules.xml b/Answers/40230112094/.idea/modules.xml new file mode 100644 index 0000000..9a73810 --- /dev/null +++ b/Answers/40230112094/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112094/.idea/vcs.xml b/Answers/40230112094/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/Answers/40230112094/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/Answers/40230112094/.idea/workspace.xml b/Answers/40230112094/.idea/workspace.xml new file mode 100644 index 0000000..243acca --- /dev/null +++ b/Answers/40230112094/.idea/workspace.xml @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + { + "associatedIndex": 1 +} + + + + + { + "keyToString": { + "Application.Main.executor": "Run", + "RunOnceActivity.OpenProjectViewOnStart": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "git-widget-placeholder": "master", + "kotlin-language-version-configured": "true", + "onboarding.tips.debug.path": "C:/Users/Pc/IdeaProjects/Functions/src/Main.java" + } +} + + + + + + + + + + + 1710248472668 + + + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112094/Functions.iml b/Answers/40230112094/Functions.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/Answers/40230112094/Functions.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/Answers/40230112094/src/Functions.java b/Answers/40230112094/src/Functions.java new file mode 100644 index 0000000..f86bdae --- /dev/null +++ b/Answers/40230112094/src/Functions.java @@ -0,0 +1,242 @@ +import java.util.*; +import java.lang.*; +public class Functions +{ + public static String fullName (String firstname, String lastname) + { + String FN = firstname.substring(0,1).toUpperCase() + firstname.substring(1).toLowerCase(); + String LN = lastname.substring(0,1).toUpperCase() + lastname.substring(1).toLowerCase(); + String fullname = FN + " " + LN; + return fullname; + } + public static String phoneNumber(String phone) + { + int length = phone.length(); + if (length == 11 & phone.startsWith("0")) + { + return phone; + } + else if (length == 10 & phone.startsWith("9")) + { + phone = "0" + phone; + return phone; + } + else + { + String error = "Wrong entry. Tty again."; + return error; + } + } + public static String userId(String id) + { + int length = id.length(); + if (length >= 4 & length <= 13) + { + return id; + } + else + { + return "Wrong entry!"; + } + } + public static String getInterests(String[] interests) + { + String showList = "{"; + for (int i=0 ; i<10 ; i++) + { + if (interests[i].equals("null")) + { + showList = showList + "X"; + showList = showList.replaceAll(", X","}"); + break; + } + showList = showList + "\"" + interests[i] + "\", "; + if (i == 9) + { + showList = showList + "X"; + showList = showList.replaceAll(", X","}"); + } + } + return showList; + } + public static String userFullInformation(String fullName, String phoneNumber, String userId, String[] interests) + { + String[] splitedname = fullName.split(" "); + String name = Functions.fullName(splitedname[0],splitedname[1]); + for (int i=0 ; i<10 ; i++) + { + if (interests[i].equals("null")) break; + interests[i] = interests[i].substring(0,1).toUpperCase() + interests[i].substring(1).toLowerCase(); + } + String massage = String.format("\nHello! My name is %s. My ID is %s. Here are some of my interests:", name, userId); + for (int i=0 ; i < interests.length ; i++) + { + if (interests[i].equals("null")) break; + massage = massage + "\n" + (i+1) + ". " + interests[i]; + } + massage = massage + String.format("\nYou can reach me via my phone number %s.\n", Functions.phoneNumber(phoneNumber)); + return massage; + } + public static String informationEncoder(String information, int shift) + { + char[] LCA = new char[26]; + char[] UCA = new char[26]; + char[] Numbers = new char[10]; + LCA[0] = 'a'; + UCA[0] = 'A'; + Numbers[0] = '0'; + for (int i=1 ; i<26 ; i++) + { + LCA[i] = (char) (LCA[i-1] + 1); + UCA[i] = (char) (UCA[i-1] + 1); + } + for (int i=1 ; i<10 ; i++) Numbers[i] = (char) (Numbers[i-1] + 1); + String[] infoInChar = information.split(" "); + int n = infoInChar.length; + int numbShift = shift; + if (shift > 9) numbShift %= 9; + if (shift > 25) shift %= 25; + for (int i=0 ; i 9) numbShift %= 9; + if (shift > 25) shift %= 25; + for (int i=0 ; i 0) + { + Trans[j] = LCA[26+k-shift]; + break; + } + else + { + Trans[j] = LCA[k-shift]; + break; + } + } + else if (Trans[j] == UCA[k]) + { + if (shift-k > 0) + { + Trans[j] = UCA[26+k-shift]; + break; + } + else + { + Trans[j] = UCA[k-shift]; + break; + } + } + } + for (int k=0 ; k<10 ; k++) + { + if (Trans[j] == Numbers[k]) + { + if (numbShift-k > 0) + { + Trans[j] = Numbers[10+k-numbShift]; + break; + } + else + { + Trans[j] = Numbers[k-numbShift]; + break; + } + } + } + infoInChar[i] = infoInChar[i] + Trans[j]; + } + } + String resault = " "; + for (int i=0 ; i 3) + { + System.out.println("Wrong entry! try again:"); + } + } + while (choose != 3); + + + + //informationEncoder +// System.out.print("Enter the information: "); +// String info = input.nextLine(); +// System.out.print("Enter shift number: "); +// int numb = input.nextInt(); +// System.out.println(Functions.informationEncoder(info,numb)); + +// Hello, my name is Aryanoor. I am learning Java.01234 + + + + //informationDecoder +// System.out.print("Enter the code: "); +// String code = input.nextLine(); +// System.out.print("Enter the shift number: "); +// int numb = input.nextInt(); +// System.out.println(Functions.informationDecoder(code,numb)); + +// Fvb mvbuk Tl jvyyljasf. 8170 + } +} \ No newline at end of file