Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
6bc53d0
copying project and making first function.
MahdiyarHastam Mar 14, 2024
49be9fe
coded the second function
MahdiyarHastam Mar 14, 2024
0fd4d8e
coded the third function
MahdiyarHastam Mar 14, 2024
bd16dd7
added a class for interests for easier use of function "get interests"
MahdiyarHastam Mar 19, 2024
0d3e30c
coded the getInterests function
MahdiyarHastam Mar 19, 2024
27cec24
informationEncoder is done.
MahdiyarHastam Mar 20, 2024
e91dca2
fixing a bug in informationencoder.
MahdiyarHastam Mar 20, 2024
3f0a52b
informationDecoder is done.
MahdiyarHastam Mar 20, 2024
662efd9
done the main file and done the menu.class resume changed.
MahdiyarHastam Mar 21, 2024
d61bc26
making some void functions into string function.
MahdiyarHastam Mar 21, 2024
28455b4
done the showlist option and encryption and decryption.
MahdiyarHastam Mar 21, 2024
0a2d8b5
removing the isactive variable(useless) and a little cleaning.
MahdiyarHastam Mar 21, 2024
43bc3f2
removing the isactive variable.
MahdiyarHastam Mar 21, 2024
190fdd5
now we can encrypt or decrypt numbers(for user id and phone number)
MahdiyarHastam Mar 21, 2024
ff891e4
a little cleaning.
MahdiyarHastam Mar 21, 2024
9e74b44
fixing the warnings.
MahdiyarHastam Mar 21, 2024
e496d02
fixing the warnings and a bug.
MahdiyarHastam Mar 21, 2024
cae0be0
a little UI for getting interests from user.
MahdiyarHastam Mar 21, 2024
20d8111
making program easier to work with.
MahdiyarHastam Mar 21, 2024
eda9190
fixing an exception in show list option(when there is no list to show)
MahdiyarHastam Mar 21, 2024
81ad2ca
fixing an exception in phone number function (when user enter number …
MahdiyarHastam Mar 21, 2024
4762951
end of project.
MahdiyarHastam Mar 22, 2024
b2049f6
some cleaning
MahdiyarHastam Mar 22, 2024
f2dbf1e
now the user cant enter more than 10 interests.
MahdiyarHastam Mar 22, 2024
b9699f2
Merge remote-tracking branch 'origin/main'
MahdiyarHastam Mar 22, 2024
a6ebf51
just add \n to a text.
MahdiyarHastam Mar 22, 2024
a783739
now the user only can enter phone number and id with numbers(not lett…
MahdiyarHastam Mar 22, 2024
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
29 changes: 29 additions & 0 deletions Answers/40230112057/.gitignore
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions Answers/40230112057/.idea/misc.xml

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

8 changes: 8 additions & 0 deletions Answers/40230112057/.idea/modules.xml

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

6 changes: 6 additions & 0 deletions Answers/40230112057/.idea/vcs.xml

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

70 changes: 70 additions & 0 deletions Answers/40230112057/.idea/workspace.xml

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

11 changes: 11 additions & 0 deletions Answers/40230112057/functt.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
70 changes: 70 additions & 0 deletions Answers/40230112057/src/ap/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
package ap;
import java.util.Scanner;

public class Main {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int menu,index=0;

resume[] obj;
obj=new resume[100];
interests[] ooj=new interests[100];
boolean done=true;
while(done){
System.out.println("****************\nmenu:\n1.add a resume\n2.show list of resumes\n3.exit\n****************");
menu=input.nextInt();
switch (menu) {
case 1 -> {
obj[index] = new resume();
String firstname;
String lastname;
System.out.println("enter your first name:");
firstname = input.next();
System.out.println("enter your last name:");
lastname = input.next();
obj[index].fullName(firstname, lastname);
String phone;
System.out.println("enter phone number:");
phone = input.next();
obj[index].phoneNumber(phone);
System.out.println("enter user id:");
String id = input.next();
obj[index].userId(id);
System.out.println("how many interests do you have?");
int n = input.nextInt();
while(n>10){
System.out.println("the maximum number of interests is 10! enter another number: ");
n = input.nextInt();
}
ooj[index] = new interests(n);
resume.getInterests(ooj[index], n);
index++;
}
case 2 -> {
if(index==0){
System.out.println("there is no list");
break;
}
System.out.println("##################");
for (int i = 0; i < index; i++)
System.out.print((i + 1) + "." + "name:" + obj[i].name + "\n");
System.out.println("##################");
System.out.println("enter the number behind the name that you want to see the encrypted resume:");
int m = input.nextInt();
System.out.println("enter the shift for encryption:");
int shift = input.nextInt();
String text1 = resume.userFullInformation(obj[m - 1].name, obj[m - 1].phone, obj[m - 1].id, ooj[m - 1]);
String text2 = resume.informationEncoder(text1, shift);
System.out.println(text2);
System.out.println("do you want it decrypted?[y/n]");
String bul = input.next();
if (bul.equals("y") || bul.equals("Y")) {
String text3 = resume.informationDecoder(text2, shift);
System.out.println("\n"+text3);
}
}
case 3 -> done = false;
}
}
}
}
22 changes: 22 additions & 0 deletions Answers/40230112057/src/ap/interests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package ap;
public class interests {
public int size=0;
public int index=0;
private String[] intrests;
public interests(int n){
size=n;
intrests=new String[n];
}
public String[] array(){
return this.intrests;
}
public void add_intrests(String neww){
this.intrests[index]=neww;
index++;
}
public String index_return(int n){
return intrests[n];
}
}


91 changes: 91 additions & 0 deletions Answers/40230112057/src/ap/resume.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
package ap;
import java.util.Scanner;
public class resume {
public String name;
public String id;
public String phone;

public void fullName(String firstName,String lastName){
String First=firstName.toLowerCase();
String Second=lastName.toLowerCase();
char[] neww1=First.toCharArray();
char[] neww2=Second.toCharArray();
neww1[0]-=32;
neww2[0]-=32;
String akhari=new String(neww1);
String akharii=new String(neww2);
this.name=akhari+" "+akharii;
}
public void phoneNumber(String phone){
Scanner input=new Scanner(System.in);
if(phone.length()==11 && phone.charAt(0)=='0' && phone.charAt(1)=='9' && phone.matches("[0-9]+")){
this.phone=phone;
return;
}

while(phone.length()!=10 || phone.charAt(0)!='9' || !phone.matches("[0-9]+")){
System.out.println("Wrong entry. Try again.");
phone=input.next();
if(phone.length()==11 && phone.charAt(0)=='0' && phone.charAt(1)=='9' && phone.matches("[0-9]+")){
this.phone=phone;
return;
}
}
this.phone="0"+phone;
}
public void userId(String id){
Scanner input=new Scanner(System.in);
while(4>=id.length() || 13<=id.length() || !id.matches("[0-9]+")){
System.out.println("Wrong entry. Try again.");
id=input.next();
}

this.id=id;
}
public static String[] getInterests(interests obj,int n){
Scanner input=new Scanner(System.in);
String temp;
for(int i=0;i<n;i++){
System.out.println("interest number"+(i+1)+": ");
temp=input.next();
if(temp.equals(""))
break;
obj.add_intrests(temp);
}
return obj.array();
}
public static String userFullInformation(String fullName, String phoneNumber, String userId, interests obj){
String text1=" Hello! My name is "+ fullName+". My ID is "+userId+". Here are some of my interests:\n";
for(int i=0;i<obj.size;i++){
String text2=(i+1)+". "+obj.index_return(i)+"\n";
text1+=text2;
}
return text1+"\nYou can reach me via my phone number "+phoneNumber+".\n";
}
public static String informationEncoder(String information,int shift){
char[] temp=information.toCharArray();
for(int i=0;i<temp.length;i++){
if(temp[i]>96 && temp[i]<123)
temp[i]+=temp[i]+shift>122 ? shift-26 :shift;
else if (temp[i]>64 && temp[i]<91)
temp[i]+=temp[i]+shift>90 ? shift-26 : shift;
else if(temp[i]>=48 && temp[i]<=57)
temp[i]+=temp[i]+shift>57 ? shift-10 : shift;

}
return new String(temp);
}
public static String informationDecoder(String information,int shift){
char[] temp=information.toCharArray();
for(int i=0;i<temp.length;i++){
if(temp[i]>96 && temp[i]<123)
temp[i]-=temp[i]-shift<97 ? shift-26 :shift;
else if (temp[i]>64 && temp[i]<91)
temp[i]-=temp[i]-shift<65 ? shift-26 : shift;
else if(temp[i]>=48 && temp[i]<=57)
temp[i]-=temp[i]-shift<48 ? shift-10 : shift;
}
return new String(temp);
}

}