diff --git a/src/Bank.java b/src/Bank.java new file mode 100644 index 0000000..f1598a2 --- /dev/null +++ b/src/Bank.java @@ -0,0 +1,205 @@ +package org.example; + +import java.util.Objects; +import java.util.Scanner; + +public class Bank extends Property implements Cityinterface{ + + public int payerID; + public int recieverID; + public int transactionID; + public float amountofMoney; + public Avatar Bankstaffs; + + + public float salary; + public float getSalary() { + return salary; + } + + public void setSalary(float salary) { + this.salary = salary; + } + + public Bank(int id, String title, String ownerID, String description, float value, float coordinate, boolean status,float salary) { + super(id, title, ownerID, description, value, coordinate, status); + this.amountofMoney = amountofMoney; + this.salary=salary; + this.id++; + } + public Bank(){ + + } + + + public int getPayerID() { + return payerID; + } + + public void setPayerID(int payerID) { + this.payerID = payerID; + } + + public int getRecieverID() { + return recieverID; + } + + public void setRecieverID(int recieverID) { + this.recieverID = recieverID; + } + + public int getTransactionID() { + return transactionID; + } + + public void setTransactionID(int transactionID) { + this.transactionID = transactionID; + } + + public float getAmountofMoney() { + return amountofMoney; + } + + public void setAmountofMoney(int amountofMoney) { + this.amountofMoney = amountofMoney; + } + + public Avatar getBankstaffs() { + return Bankstaffs; + } + + public void setBankstaffs(Avatar bankstaffs) { + Bankstaffs = bankstaffs; + } + + @Override + public String toString() { + return "Bank{" + + "Bankstaffs=" + Bankstaffs + + ", title='" + title + '\'' + + ", owner-username=" + ownerusername + + ", description='" + description + '\'' + + ", value=" + value + + ", coordinate=" + coordinate + + ", status=" + status + + '}'; + } + + @Override + public void menu() { + + } + + @Override + public void UseProperty(String username) { + Avatar avatar = null; + for (Avatar i : Game.city.getAvatars()) { + if (Objects.equals(i.getUsername(), username)) { + avatar = i; + } + } + assert avatar != null; + avatar.setCoordinate(Game.city.getBanks().get(1).getCoordinate()); + avatar.setHealth(avatar.health-=5); + avatar.setFood(avatar.Food-=5); + avatar.setWater(avatar.Water-=5); + DataBase.updateInfo("avatars","health",username,avatar.health-=5); + DataBase.updateInfo("avatars","food",username,avatar.Food-=5); + DataBase.updateInfo("avatars","water",username,avatar.Water-=5); + DataBase.updateInfo("avatars","coordinate",username,Game.city.getBanks().get(1).getCoordinate()); + boolean check=true; + + while (check){ + System.out.println("Which one do you want to do?"); + System.out.println("1. Give money to another"); + System.out.println("2. Take money from another"); + System.out.println("3. Buy"); + System.out.println("4. Back to User Menu"); + Scanner scanner=new Scanner(System.in); + int n=scanner.nextInt(); + switch (n){ + case 1: + + System.out.println("Username of that Person:"); + String name=scanner.nextLine(); + System.out.println("A mount of Money that you want to give:"); + float some=scanner.nextFloat(); + for (Avatar a:Game.city.getAvatars()){ + if (Objects.equals(a.getUsername(), name)){ + + Avatar avatar1 = null; + for (Avatar i : Game.city.getAvatars()) { + if (Objects.equals(i.getUsername(), name)) { + avatar1 = i; + } + } + assert avatar1 != null; + avatar.setMoney(avatar.money-=some); + avatar1.setMoney(avatar1.money+=some); + DataBase.updateInfo("avatars","money",username,avatar.money-=some); + DataBase.updateInfo("avatars","money",name,avatar1.money+=some); + + } + } + check=false; + break; + + case 2: + + + System.out.println("Username of that Person:"); + String name1=scanner.nextLine(); + System.out.println("A mount of Money that you want to take:"); + float some1=scanner.nextFloat(); + for (Avatar a:Game.city.getAvatars()){ + if (Objects.equals(a.getUsername(), name1)){ + + Avatar avatar1 = null; + for (Avatar i : Game.city.getAvatars()) { + if (Objects.equals(i.getUsername(), name1)) { + avatar1 = i; + } + } + assert avatar1 != null; + avatar.setMoney(avatar.money+=some1); + avatar1.setMoney(avatar1.money-=some1); + DataBase.updateInfo("avatars","money",username,avatar.money+=some1); + DataBase.updateInfo("avatars","money",name1,avatar1.money-=some1); + + } + } + check=false; + break; + + + case 3: + + + check=false; + break; + + case 4: + + Menu.showUserMenu(); + check=false; + break; + default: + + System.out.println("Wrong choice!!!"); + } + } + + } + + @Override + public void buy() { + + } + + @Override + public void sell() { + + } + + +} diff --git a/src/Boutique.java b/src/Boutique.java new file mode 100644 index 0000000..e7e784f --- /dev/null +++ b/src/Boutique.java @@ -0,0 +1,185 @@ +package org.example; + +import java.util.Objects; +import java.util.Scanner; + +public class Boutique extends Property implements Cityinterface{ + + public String dress; + public static float dressprice=0.5f; + public String shoe; + public static float shoeprice=0.25f; + public String hat; + public static float hatprice=0.1f; + public Avatar Boutiquestaffs; + + public float salary; + + public Boutique(int id, String title, String ownerID, String description, float value, float coordinate, boolean status,float salary) { + super(id, title, ownerID, description, value, coordinate, status); + this.salary=salary; + this.id++; + } + + public Boutique(){ + + } + + public float getSalary() { + return salary; + } + + public void setSalary(float salary) { + this.salary = salary; + } + + public String getDress() { + return dress; + } + + public void setDress(String dress) { + this.dress = dress; + } + + public float getDressprice() { + return dressprice; + } + + public void setDressprice(float dressprice) { + this.dressprice = dressprice; + } + + public String getShoe() { + return shoe; + } + + public void setShoe(String shoe) { + this.shoe = shoe; + } + + public float getShoeprice() { + return shoeprice; + } + + public void setShoeprice(float shoeprice) { + this.shoeprice = shoeprice; + } + + public String getHat() { + return hat; + } + + public void setHat(String hat) { + this.hat = hat; + } + + public float getHatprice() { + return hatprice; + } + + public void setHatprice(float hatprice) { + this.hatprice = hatprice; + } + + public Avatar getBoutiquestaffs() { + return Boutiquestaffs; + } + + public void setBoutiquestaffs(Avatar boutiquestaffs) { + Boutiquestaffs = boutiquestaffs; + } + + @Override + public String toString() { + return "Boutique{" + + ", Boutiquestaffs=" + Boutiquestaffs + + ", title='" + title + '\'' + + ", owner-username=" + ownerusername + + ", description='" + description + '\'' + + ", value=" + value + + ", coordinate=" + coordinate + + ", status=" + status + + '}'; + } + + @Override + public void menu() { + + } + + @Override + public void UseProperty(String username) { + + Avatar avatar = null; + for (Avatar i : Game.city.getAvatars()) { + if (Objects.equals(i.getUsername(), username)) { + avatar = i; + } + } + assert avatar != null; + avatar.setCoordinate(Game.city.getBoutiques().get(1).getCoordinate()); + avatar.setHealth(avatar.health-=5); + avatar.setFood(avatar.Food-=5); + avatar.setWater(avatar.Water-=5); + DataBase.updateInfo("avatars","health",username,avatar.health-=5); + DataBase.updateInfo("avatars","food",username,avatar.Food-=5); + DataBase.updateInfo("avatars","water",username,avatar.Water-=5); + DataBase.updateInfo("avatars","coordinate",username,Game.city.getBoutiques().get(1).getCoordinate()); + boolean check=true; + while (check){ + System.out.println("Which one do you want to buy?"); + System.out.println("1. Dress"); + System.out.println("2. Shoe"); + System.out.println("3. Hat"); + System.out.println("4. Back to User Menu"); + Scanner scanner=new Scanner(System.in); + int n=scanner.nextInt(); + switch (n){ + case 1: + System.out.println("You bought some Dress"); + avatar.setMoney(avatar.money-=dressprice); + DataBase.updateInfo("avatars","money",username,avatar.money-=dressprice); + check=false; + break; + + case 2: + + System.out.println("You bought some Show"); + avatar.setMoney(avatar.money-=shoeprice); + DataBase.updateInfo("avatars","money",username,avatar.money-=shoeprice); + check=false; + break; + + + case 3: + + System.out.println("You bought some Hat"); + avatar.setMoney(avatar.money-=hatprice); + DataBase.updateInfo("avatars","money",username,avatar.money-=hatprice); + check=false; + break; + + case 4: + + Menu.showUserMenu(); + check=false; + break; + default: + + System.out.println("Wrong choice!!!"); + } + } + } + + @Override + public void buy() { + + } + + @Override + public void sell() { + + } + + +} diff --git a/src/Clinic.java b/src/Clinic.java new file mode 100644 index 0000000..ce1236a --- /dev/null +++ b/src/Clinic.java @@ -0,0 +1,148 @@ +package org.example; + +import java.util.ArrayList; +import java.util.Objects; +import java.util.Scanner; + +public class Clinic extends Property implements Cityinterface{ + + public static Avatar Doctors; + public static Avatar Nurses; + public ArrayList patients; + + public static float fee=1; + + + public float salary; + public float getSalary() { + return salary; + } + + public void setSalary(float salary) { + this.salary = salary; + } + public Clinic(int id, String title, String ownerID, String description, float value, float coordinate, boolean status, Avatar doctors, Avatar nurses,float salary) { + super(id, title, ownerID, description, value, coordinate, status); + this.salary=salary; + Doctors = doctors; + Nurses = nurses; + ArrayList patients=new ArrayList<>(); + this.id++; + + } + + public Clinic(){ + + } + + + public Avatar getDoctors() { + return Doctors; + } + + public void setDoctors(Avatar doctors) { + Doctors = doctors; + } + + public Avatar getNurses() { + return Nurses; + } + + public void setNurses(Avatar nurses) { + Nurses = nurses; + } + + + public ArrayList getPatients() { + return patients; + } + + public void setPatients(ArrayList patients) { + this.patients = patients; + } + + @Override + public String toString() { + return "Clinic{" + + ", doctors="+ getDoctors()+ + ", nurses="+ getNurses()+ + "patients=" + patients + + ", title='" + title + '\'' + + ", owner-username=" + ownerusername + + ", description='" + description + '\'' + + ", value=" + value + + ", coordinate=" + coordinate + + ", status=" + status + + '}'; + } + + @Override + public void menu() { + + } + + @Override + public void UseProperty(String username) { + + Avatar avatar = null; + for (Avatar i : Game.city.getAvatars()) { + if (Objects.equals(i.getUsername(), username)) { + avatar = i; + } + } + assert avatar != null; + avatar.setCoordinate(Game.city.getClinics().get(1).getCoordinate()); + avatar.setHealth(avatar.health-=5); + avatar.setFood(avatar.Food-=5); + avatar.setWater(avatar.Water-=5); + DataBase.updateInfo("avatars","health",username,avatar.health-=5); + DataBase.updateInfo("avatars","food",username,avatar.Food-=5); + DataBase.updateInfo("avatars","water",username,avatar.Water-=5); + DataBase.updateInfo("avatars","coordinate",username,Game.city.getClinics().get(1).getCoordinate()); + boolean check=true; + + + while (check) { + System.out.println("Which one do you want to do?"); + System.out.println("1. Have visit With Doctor:"); + System.out.println("2. Take some Medicine:"); + System.out.println("3. Back to User Menu"); + Scanner scanner = new Scanner(System.in); + int n = scanner.nextInt(); + switch (n) { + + case 1: + System.out.println("You have visit wih doctor"); + avatar.setMoney(avatar.money-=fee); + DataBase.updateInfo("avatars","money",username,avatar.money-=fee); + check=false; + break; + + case 2: + + System.out.println("You bought some medicine"); + avatar.setMoney(avatar.money-=fee); + DataBase.updateInfo("avatars","money",username,avatar.money-=fee); + check=false; + break; + case 3: + + Menu.showUserMenu(); + check=false; + break; + default: + } + } + } + + @Override + public void buy() { + + } + + @Override + public void sell() { + + } + +} diff --git a/src/Club.java b/src/Club.java new file mode 100644 index 0000000..c902d17 --- /dev/null +++ b/src/Club.java @@ -0,0 +1,5 @@ +package org.example; + +public class Club { + //this is niiiiiiiiiightttt clubbbbbbbbb +} diff --git a/src/EncryptionUtils.java b/src/EncryptionUtils.java new file mode 100644 index 0000000..ae6414d --- /dev/null +++ b/src/EncryptionUtils.java @@ -0,0 +1,30 @@ +package org.example; + +import javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +public class EncryptionUtils { + + private static final String ALGORITHM = "AES"; + private static final String SECRET_KEY = "amirreza15101382"; // 16 characters for AES-128, 24 characters for AES-192, and 32 characters for AES-256 + + public static String encrypt(String data) throws Exception { + SecretKeySpec secretKeySpec = new SecretKeySpec(SECRET_KEY.getBytes(StandardCharsets.UTF_8), ALGORITHM); + Cipher cipher = Cipher.getInstance(ALGORITHM); + cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec); + + byte[] encryptedBytes = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8)); + return Base64.getEncoder().encodeToString(encryptedBytes); + } + + public static String decrypt(String encryptedData) throws Exception { + SecretKeySpec secretKeySpec = new SecretKeySpec(SECRET_KEY.getBytes(StandardCharsets.UTF_8), ALGORITHM); + Cipher cipher = Cipher.getInstance(ALGORITHM); + cipher.init(Cipher.DECRYPT_MODE, secretKeySpec); + + byte[] decryptedBytes = cipher.doFinal(Base64.getDecoder().decode(encryptedData)); + return new String(decryptedBytes, StandardCharsets.UTF_8); + } + +} diff --git a/src/Factory.java b/src/Factory.java new file mode 100644 index 0000000..62a24b5 --- /dev/null +++ b/src/Factory.java @@ -0,0 +1,164 @@ +package org.example; + +import java.util.Objects; +import java.util.Scanner; + +public class Factory extends Property implements Cityinterface{ + + public String product; + public float carpetprice=0.2f; + public float clothprice=0.15f; + public float threadprice=0.1f; + + public float productprice; + public float output; + public Avatar factorystaffs; + + + public float salary; + public float getSalary() { + return salary; + } + + public void setSalary(float salary) { + this.salary = salary; + } + + public Factory(int id, String title, String ownerID, String description, float value, float coordinate, boolean status, float output,float salary) { + super(id, title, ownerID, description, value, coordinate, status); + this.salary=salary; + this.output = output; + this.id++; + } + + public Factory(){ + + } + public String getProduct() { + return product; + } + + public void setProduct(String product) { + this.product = product; + } + + public float getProductprice() { + return productprice; + } + + public void setProductprice(float productprice) { + this.productprice = productprice; + } + + public float getOutput() { + return output; + } + + public void setOutput(float output) { + this.output = output; + } + + public Avatar getFactorystaffs() { + return factorystaffs; + } + + public void setFactorystaffs(Avatar factorystaffs) { + this.factorystaffs = factorystaffs; + } + + @Override + public String toString() { + return "Factory{" + + ", output='" + output + '\'' + + ", factorystaffs=" + factorystaffs + + ", title='" + title + '\'' + + ", owner-username=" + ownerusername + + ", description='" + description + '\'' + + ", value=" + value + + ", coordinate=" + coordinate + + ", status=" + status + + '}'; + } + + @Override + public void menu() { + + } + + @Override + public void buy() { + + } + + @Override + public void sell() { + + } + + + public void UseProperty(String username) { + + + Avatar avatar = null; + for (Avatar i : Game.city.getAvatars()) { + if (Objects.equals(i.getUsername(), username)) { + avatar = i; + } + } + assert avatar != null; + avatar.setCoordinate(Game.city.getFactories().get(1).getCoordinate()); + avatar.setHealth(avatar.health -= 5); + avatar.setFood(avatar.Food -= 5); + avatar.setWater(avatar.Water -= 5); + DataBase.updateInfo("avatars", "health", username, avatar.health -= 5); + DataBase.updateInfo("avatars", "food", username, avatar.Food -= 5); + DataBase.updateInfo("avatars", "water", username, avatar.Water -= 5); + DataBase.updateInfo("avatars", "coordinate", username, Game.city.getFactories().get(1).getCoordinate()); + boolean check = true; + + while (check) { + System.out.println("Which one do you want to do?"); + System.out.println("1. Buy some Carpet:"); + System.out.println("2. Buy some Cloth:"); + System.out.println("3. Buy some Thread:"); + System.out.println("4. Back to User Menu"); + Scanner scanner = new Scanner(System.in); + int n = scanner.nextInt(); + switch (n) { + + case 1: + + System.out.println("You Bought a Carpet"); + avatar.setMoney(avatar.money-=carpetprice); + DataBase.updateInfo("avatars","money",username,avatar.money-=carpetprice); + check=false; + break; + + case 2: + + + System.out.println("You Bought a Cloth"); + avatar.setMoney(avatar.money-=clothprice); + DataBase.updateInfo("avatars","money",username,avatar.money-=clothprice); + check=false; + break; + case 3: + + + System.out.println("You Bought a Thread"); + avatar.setMoney(avatar.money-=threadprice); + DataBase.updateInfo("avatars","money",username,avatar.money-=threadprice); + check=false; + break; + + case 4: + + Menu.showUserMenu(); + check=false; + break; + default: + + } + } + } +} diff --git a/src/Gamenet.java b/src/Gamenet.java new file mode 100644 index 0000000..c2b7883 --- /dev/null +++ b/src/Gamenet.java @@ -0,0 +1,4 @@ +package org.example; + +public class Gamenet { +} diff --git a/src/Property.java b/src/Property.java new file mode 100644 index 0000000..14f3332 --- /dev/null +++ b/src/Property.java @@ -0,0 +1,160 @@ +package org.example; + +import java.util.ArrayList; + +public class Property { + + + protected int id; + protected String title; + protected String ownerusername; + protected String description; + protected float value; + protected float coordinate; + protected boolean status; + + public Property(int id,String title,String ownerusername,String description,float value,float coordinate,boolean status){ + + this.id =id; + this.title=title; + this.ownerusername=ownerusername; + this.description=description; + this.value=value; + this.coordinate=coordinate; + this.status=status; + + } + public Property(){ + + } + + //public + + public static Object FindProperty(int id) { + Bank bank = null; + Boutique boutique = null; + Clinic clinic = null; + Factory factory = null; + Home home = null; + Land land = null; + Restaurant restaurant = null; + Supermarket supermarket = null; + for (Bank b : Game.city.getBanks()) { + if (b.getId() == id) { + return b; + } + } + for (Boutique b : Game.city.getBoutiques()) { + if (b.getId() == id) { + return b; + } + } + + for (Home h : Game.city.getHomes()) { + if (h.getId() == id) { + return h; + } + } + + for (Restaurant r : Game.city.getRestaurants()) { + if (r.getId() == id) { + return r; + } + } + + for (Supermarket s : Game.city.getSupermarkets()) { + if (s.getId() == id) { + return s; + } + } + + for (Land l : Game.city.getLands()) { + if (l.getId() == id) { + return l; + } + } + for (Clinic c : Game.city.getClinics()) { + if (c.getId() == id) { + return c; + } + } + for (Factory f : Game.city.getFactories()) { + if (f.getId() == id) { + return f; + } + } + return null; + } + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getOwnerusername() { + return ownerusername; + } + + public void setOwnerID(String ownerusername) { + this.ownerusername = ownerusername; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public float getValue() { + return value; + } + + public void setValue(float value) { + this.value = value; + } + + public float getCoordinate() { + return coordinate; + } + + public void setCoordinate(float coordinate) { + this.coordinate = coordinate; + } + + public boolean isStatus() { + return status; + } + + public void setStatus(boolean status) { + this.status = status; + } + + + @Override + public String toString() { + return "Property{" + + "id='" + id + '\'' + + "title='" + title + '\'' + + ", owner-username=" + ownerusername + + ", description='" + description + '\'' + + ", value=" + value + + ", coordinate=" + coordinate + + ", status=" + status + + '}'; + } + + +}