diff --git a/Week 2 Assignment 1/Factorial_W2A1_3.class b/Week 2 Assignment 1/Factorial_W2A1_3.class
new file mode 100644
index 0000000..d3ba8bf
Binary files /dev/null and b/Week 2 Assignment 1/Factorial_W2A1_3.class differ
diff --git a/Week 2 Assignment 1/Factorial_W2A1_3.java b/Week 2 Assignment 1/Factorial_W2A1_3.java
new file mode 100644
index 0000000..51a4a39
--- /dev/null
+++ b/Week 2 Assignment 1/Factorial_W2A1_3.java
@@ -0,0 +1,15 @@
+public class Factorial_W2A1_3 {
+ static int product = 1;
+ public static void main(String args[]) {
+ int num = 4;
+ System.out.println(recursion(num));
+ }
+
+ static int recursion(int num) {
+ if(num > 0) {
+ product = product * num;
+ recursion(num - 1);
+ }
+ return product;
+ }
+}
\ No newline at end of file
diff --git a/Week 2 Assignment 1/Fibonacci_W2A1_1.class b/Week 2 Assignment 1/Fibonacci_W2A1_1.class
new file mode 100644
index 0000000..321640c
Binary files /dev/null and b/Week 2 Assignment 1/Fibonacci_W2A1_1.class differ
diff --git a/Week 2 Assignment 1/Fibonacci_W2A1_1.java b/Week 2 Assignment 1/Fibonacci_W2A1_1.java
new file mode 100644
index 0000000..9e7b898
--- /dev/null
+++ b/Week 2 Assignment 1/Fibonacci_W2A1_1.java
@@ -0,0 +1,18 @@
+public class Fibonacci_W2A1_1 {
+ static int temp1 = 0, temp2 = 1, temp3 = 0;
+ public static void main(String arg[]) {
+ int num = 9;
+ System.out.print(temp1 + " " + temp2 + " ");
+ recursion(num);
+ }
+
+ static void recursion(int num) {
+ if(num > 0) {
+ temp3 = temp1 + temp2;
+ temp1 = temp2;
+ temp2 = temp3;
+ System.out.print(temp3 + " ");
+ recursion(num - 1);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Week 2 Assignment 1/Reverse_W2A1_4.class b/Week 2 Assignment 1/Reverse_W2A1_4.class
new file mode 100644
index 0000000..8212dc7
Binary files /dev/null and b/Week 2 Assignment 1/Reverse_W2A1_4.class differ
diff --git a/Week 2 Assignment 1/Reverse_W2A1_4.java b/Week 2 Assignment 1/Reverse_W2A1_4.java
new file mode 100644
index 0000000..74167d9
--- /dev/null
+++ b/Week 2 Assignment 1/Reverse_W2A1_4.java
@@ -0,0 +1,19 @@
+import java.util.Arrays;
+
+public class Reverse_W2A1_4 {
+ static int[] arr = {3,4,6,7,9};
+ static int[] reversedArray = new int[arr.length];
+ static int counter = 0;
+ public static void main(String args[]) {
+ System.out.println(recursion(arr.length));
+ }
+
+ static String recursion(int arrLength) {
+ if(arrLength > 0) {
+ reversedArray[counter] = arr[(arr.length - 1) - counter];
+ counter++;
+ recursion(arrLength - 1);
+ }
+ return Arrays.toString(reversedArray);
+ }
+}
\ No newline at end of file
diff --git a/Week 2 Assignment 1/SumOFArray_W2A1_2.class b/Week 2 Assignment 1/SumOFArray_W2A1_2.class
new file mode 100644
index 0000000..4628b3c
Binary files /dev/null and b/Week 2 Assignment 1/SumOFArray_W2A1_2.class differ
diff --git a/Week 2 Assignment 1/SumOFArray_W2A1_2.java b/Week 2 Assignment 1/SumOFArray_W2A1_2.java
new file mode 100644
index 0000000..15ce919
--- /dev/null
+++ b/Week 2 Assignment 1/SumOFArray_W2A1_2.java
@@ -0,0 +1,15 @@
+public class SumOFArray_W2A1_2 {
+ static int sum = 0, i = 0;
+ static int[] arr = {3,4,2,7,9};
+ public static void main(String args[]) {
+ System.out.println(recursion(arr.length));
+ }
+ static int recursion(int arrLength) {
+ if(arrLength > 0) {
+ sum += arr[i];
+ i++;
+ recursion(arrLength - 1);
+ }
+ return sum;
+ }
+}
\ No newline at end of file
diff --git a/Week 2 Assignment 2/PizzaShop_W2A2_1.class b/Week 2 Assignment 2/PizzaShop_W2A2_1.class
new file mode 100644
index 0000000..7a65ecb
Binary files /dev/null and b/Week 2 Assignment 2/PizzaShop_W2A2_1.class differ
diff --git a/Week 2 Assignment 2/PizzaShop_W2A2_1.java b/Week 2 Assignment 2/PizzaShop_W2A2_1.java
new file mode 100644
index 0000000..d08f246
--- /dev/null
+++ b/Week 2 Assignment 2/PizzaShop_W2A2_1.java
@@ -0,0 +1,106 @@
+import java.util.Scanner;
+
+public class PizzaShop_W2A2_1 {
+ private String[] crust = {"Thin Crust", "Cheese Burst", "Classic Pan"};
+ private int crustOption;
+ private int[] crustPrice = {100, 200, 300};
+
+ private String[] toppings = {"Corn", "Chicken", "Paneer", "Pineapple", "Pepperoni"};
+ private int toppingsOption;
+ private int[] toppingsPrice = {100, 200, 300, 400, 500};
+
+ private String[] sides = {"Coke", "Fries", "Wedges", "Nachos"};
+ private int sidesOption;
+ private int[] sidesPrice = {100, 200, 300, 400};
+
+ private int[] offerTypes = {20, 50};
+ private int offerOption = 0;
+
+ private double price;
+ private double discount;
+ //crusttype, toppings, sides, offers, price
+
+ public void getPrice() {
+ price = crustPrice[crustOption] + toppingsPrice[toppingsOption] + sidesPrice[sidesOption];
+ if(offerOption > 0) {
+ discount = offerTypes[offerOption - 1] / 100.00;
+ discount = price * discount;
+ price = price - discount;
+ }
+ System.out.println("Total: Rs " + price);
+ }
+
+ public void setOffer(int option) {
+ offerOption = option;
+ }
+
+ public void getOffer() {
+ for(int i = 0; i < offerTypes.length; i++) {
+ System.out.print((i + 1) + " " + offerTypes[i] + "% Off\n");
+ }
+ }
+
+ public void setSides(int option) {
+ sidesOption = option - 1;
+ }
+
+ public void getSides() {
+ for(int i = 0; i < sides.length; i++) {
+ System.out.print((i + 1) + " " + sides[i] + " Rs " + sidesPrice[i] + "\n");
+ }
+ }
+
+ public void setToppings(int option) {
+ toppingsOption = option - 1;
+ }
+
+ public void getToppings() {
+ for(int i = 0; i < toppings.length; i++) {
+ System.out.print((i + 1) + " " + toppings[i] + " Rs " + toppingsPrice[i] + "\n");
+ }
+ }
+
+ public void setCrust(int option) {
+ crustOption = option - 1;
+ }
+
+ public void getCrust() {
+ for(int i = 0; i < crust.length; i++) {
+ System.out.print((i + 1) + " " + crust[i] + " Rs " + crustPrice[i] + "\n");
+ }
+ }
+
+ public static void main(String args[]) {
+ Scanner scans = new Scanner(System.in);
+ PizzaShop_W2A2_1 pizzaShop = new PizzaShop_W2A2_1();
+ int option;
+ String offerGiven;
+ System.out.println("Select from below");
+
+ System.out.println("Crust:");
+ pizzaShop.getCrust();
+ option = scans.nextInt();
+ pizzaShop.setCrust(option);
+
+ System.out.println("Toppings: ");
+ pizzaShop.getToppings();
+ option = scans.nextInt();
+ pizzaShop.setToppings(option);
+
+ System.out.println("Sides: ");
+ pizzaShop.getSides();
+ option = scans.nextInt();
+ pizzaShop.setSides(option);
+
+ System.out.println("Any discounts to be applied?\ny/n");
+ offerGiven = scans.next();
+ if(offerGiven.equals("y")) {
+ System.out.println("Offers: ");
+ pizzaShop.getOffer();
+ option = scans.nextInt();
+ pizzaShop.setOffer(option);
+ }
+ pizzaShop.getPrice();
+ scans.close();
+ }
+}
\ No newline at end of file
diff --git a/Week 2 Assignment 2/PizzaShop_W2A2_1_v2.java b/Week 2 Assignment 2/PizzaShop_W2A2_1_v2.java
new file mode 100644
index 0000000..fdfb913
--- /dev/null
+++ b/Week 2 Assignment 2/PizzaShop_W2A2_1_v2.java
@@ -0,0 +1,54 @@
+public class PizzaShop_W2A2_1_v2 {
+ private String crustType;
+ private String toppingType;
+ private String sidesType;
+ private int offers;
+ private boolean offerApplied = false;
+ private double price;
+ private double discount;
+
+ private int crustTypeAmount;
+ //crusttype, toppings, sides, offers, price
+ PizzaShop_W2A2_1_v2(String crust, String topping, String sides) {
+ crustType = crust;
+ toppingType = topping;
+ sidesType = sides;
+ }
+
+ PizzaShop_W2A2_1_v2(String crust, String topping, String sides, int offer) {
+ crustType = crust;
+ toppingType = topping;
+ sidesType = sides;
+ offers = offer;
+ offerApplied = true;
+ }
+
+ // private int getCrustPrice() {
+ // switch(crustType) {
+ // case "thinCrust":
+ // crustTypeAmount = 100;
+ // break;
+ // case "cheeseBurst":
+ // crustTypeAmount = 200;
+ // break;
+ // case "classicPan":
+ // crustTypeAmount = 300;
+ // break;
+ // }
+ // }
+
+ public double calculateTotalPrice() {
+ //logic to calculate price here
+ return price;
+ }
+ public static void main(String arg[]) {
+ //(crustType, toppingType, sidesType)
+ PizzaShop_W2A2_1_v2 pizzaWithoutOffer = new PizzaShop_W2A2_1_v2("Thin Crust", "Corn", "Fries");
+ System.out.println("Total price: " + pizzaWithoutOffer.calculateTotalPrice());
+
+ //20% off applied
+ //(crustType, toppingType, sidesType, offerDiscount)
+ PizzaShop_W2A2_1_v2 pizzaWithOfferApplied = new PizzaShop_W2A2_1_v2("Thin Crust", "Cheese Burst", "Classic Pan", 20);
+ System.out.println("Total price: " + pizzaWithOfferApplied.calculateTotalPrice());
+ }
+}
\ No newline at end of file
diff --git a/Week 2 Assignment 3/SavingsAccount_W2A2_2.java b/Week 2 Assignment 3/SavingsAccount_W2A2_2.java
new file mode 100644
index 0000000..516aed6
--- /dev/null
+++ b/Week 2 Assignment 3/SavingsAccount_W2A2_2.java
@@ -0,0 +1,44 @@
+public class SavingsAccount_W2A2_2 {
+ private double balance;
+ private String customerName;
+ private int customerAge;
+ private String nomineeName;
+ private long panNumber;
+ private boolean withdraw = false;
+ private boolean deposit = false;
+
+ public SavingsAccount_W2A2_2(String custName, int custAge, long panNo) {
+ customerName = custName;
+ customerAge = custAge;
+ panNumber = panNo;
+ }
+
+ public void updateNomineeDetails(String name) {
+ nomineeName = name;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void withdraw(String withdrawUsing) {
+ if(withdrawUsing.equals("withdrawSlip") || withdrawUsing.equals("atm")) {
+ withdraw = true;
+ }
+ if(withdraw) {
+ //withdraw money code here
+ }
+ }
+
+ public void deposit(String depositUsing) {
+ if(depositUsing.equals("challan") || depositUsing.equals("atm")) {
+ deposit = true;
+ }
+ if(deposit) {
+ //deposit money code here
+ }
+ }
+ public static void main(String args[]) {
+
+ }
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 1/BankAccount.class b/Week 3 Assignment 1/BankAccount.class
new file mode 100644
index 0000000..993ea6b
Binary files /dev/null and b/Week 3 Assignment 1/BankAccount.class differ
diff --git a/Week 3 Assignment 1/BankAccountClient_W3A1_2.java b/Week 3 Assignment 1/BankAccountClient_W3A1_2.java
new file mode 100644
index 0000000..64c78ad
--- /dev/null
+++ b/Week 3 Assignment 1/BankAccountClient_W3A1_2.java
@@ -0,0 +1,209 @@
+// a. A BankAccount will contain the account holders name, account number,
+// the account creation date (string as of now), branch name and balance and Address
+
+// b. A BankAccount can be either SavingsAccount or CurrentAccount or Salaried Account (a special type of savings account)
+// c. Current account holders do not have withdrawal limit on their account balance whereas Savings account holders
+// can only withdraw 25000 per day.
+// d. CurrentAccount holders should have a minimum account balance of Rs 25000. Regular savings account holders should
+// maintain 10000 rupees whereas Salaried account holders can maintain 0 balance.
+// e. There should be a provision to update Nominee details but they cannot update account number and name.
+// f. The address should contain FlatNo, Street, City, State and pin code.
+import java.util.Arrays;
+
+abstract class BankAccount {
+ private String acHolderName;
+ private int acNumber;
+ private String acCreationDate;
+ public String branchName;
+ private static double balance;
+ public String[] address;
+
+ public BankAccount(String acHolderName, int acNumber, String acCreationDate, String branchName, double bal, String[] address) {
+ this.acHolderName = acHolderName;
+ this.acNumber = acNumber;
+ this.acCreationDate = acCreationDate;
+ this.branchName = branchName;
+ balance = bal;
+ this.address = address;
+ }
+
+ public double getBalance() {
+ return balance;
+ }
+
+ public void setBalance(double bal) {
+ balance = bal;
+ }
+
+ abstract void updateNomineeDetails(String branchName, String[] address);
+
+ public String getAcHolderName() {
+ return acHolderName;
+ }
+ public int getAcNumber() {
+ return acNumber;
+ }
+ public String getAcCreationDate() {
+ return acCreationDate;
+ }
+ public String getBranchName() {
+ return branchName;
+ }
+ public String getAddress() {
+ return Arrays.toString(address);
+ }
+ abstract void getAccDetails();
+}
+
+interface accountRules {
+ void withdrawFunc(double amount);
+ boolean minAcBalanceMaintained();
+}
+
+class SavingsAccount extends BankAccount implements accountRules {
+
+ public static double withdrawLimit = 25_000; // per day
+ private static double minAcBalAmount = 10_000;
+
+ public SavingsAccount(String acHolderName, int acNumber, String acCreationDate, String branchName, double balance,
+ String[] address) {
+ super(acHolderName, acNumber, acCreationDate, branchName, balance, address);
+ }
+
+ @Override
+ public void withdrawFunc(double amount) {
+ if(amount < withdrawLimit && getBalance() > minAcBalAmount) {
+ setBalance(getBalance() - amount);
+ }
+ }
+
+ @Override
+ public boolean minAcBalanceMaintained() {
+ if(getBalance() < minAcBalAmount) {
+ return false;
+ }
+ else return true;
+ }
+
+ @Override
+ void updateNomineeDetails(String branchName, String[] address) {
+ this.branchName = branchName;
+ this.address = address;
+ }
+
+ public void getAccDetails() {
+ System.out.println(
+ "\nAccount holder name: " + getAcHolderName() +
+ "\nAccount number: " + getAcNumber() +
+ "\nAccount creation date: " + getAcCreationDate() +
+ "\nBranch name: " + getBranchName() +
+ "\nAddress: " + getAddress()
+ );
+ }
+}
+
+class CurrentAccount extends BankAccount implements accountRules {
+
+ private static double minAcBalAmount = 25_000;
+
+ public CurrentAccount(String acHolderName, int acNumber, String acCreationDate, String branchName, double bal,
+ String[] address) {
+ super(acHolderName, acNumber, acCreationDate, branchName, bal, address);
+ }
+
+ @Override
+ public void withdrawFunc(double amount) {
+ if(getBalance() > minAcBalAmount) {
+ setBalance(getBalance() - amount);
+ }
+ }
+
+ @Override
+ public boolean minAcBalanceMaintained() {
+ if(getBalance() < minAcBalAmount) {
+ return false;
+ }
+ else return true;
+ }
+
+ @Override
+ void updateNomineeDetails(String branchName, String[] address) {
+ this.branchName = branchName;
+ this.address = address;
+ }
+
+ @Override
+ public void getAccDetails() {
+ System.out.println(
+ "\nAccount holder name: " + getAcHolderName() +
+ "\nAccount number: " + getAcNumber() +
+ "\nAccount creation date: " + getAcCreationDate() +
+ "\nBranch name: " + getBranchName() +
+ "\nAddress: " + getAddress()
+ );
+ }
+}
+
+class SalariedAccount extends SavingsAccount implements accountRules {
+
+ private static double minAcBalAmount = 0;
+
+ public SalariedAccount(String acHolderName, int acNumber, String acCreationDate, String branchName, double balance,
+ String[] address) {
+ super(acHolderName, acNumber, acCreationDate, branchName, balance, address);
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void withdrawFunc(double amount) {
+ if(getBalance() > minAcBalAmount) {
+ setBalance(getBalance() - amount);
+ }
+ }
+
+ @Override
+ public boolean minAcBalanceMaintained() {
+ if(getBalance() < minAcBalAmount) {
+ return false;
+ }
+ else return true;
+ }
+
+ @Override
+ void updateNomineeDetails(String branchName, String[] address) {
+ this.branchName = branchName;
+ this.address = address;
+ }
+
+ @Override
+ public void getAccDetails() {
+ System.out.println(
+ "\nAccount holder name: " + getAcHolderName() +
+ "\nAccount number: " + getAcNumber() +
+ "\nAccount creation date: " + getAcCreationDate() +
+ "\nBranch name: " + getBranchName() +
+ "\nAddress: " + getAddress()
+ );
+ }
+}
+
+public class BankAccountClient_W3A1_2 {
+ public static void main(String args[]) {
+ String[] address1 = {"Flat No 56", "Street 71", "City31", "State18", "577902"};
+ //adding a new savings account
+ SavingsAccount acc1 = new SavingsAccount("anon1", 12, "today", "bdvt", 13000, address1);
+ acc1.withdrawFunc(2000); //withdrawing money as per the withdrawal and minimum balance rules
+ //System.out.println(acc1.getBalance());
+ //System.out.println(acc1.minAcBalanceMaintained());
+ acc1.getAccDetails();
+ SavingsAccount acc2 = new SavingsAccount("anon2", 12, "today", "bdvt", 13000, address1);
+ //acc2.getAccDetails();
+ String[] address2 = {"Flat No 3", "Street 7", "City1", "State10", "577291"};
+ acc1.updateNomineeDetails("smg", address2);
+ acc1.getAccDetails();
+
+ String[] address3 = {"dummydata"};
+ CurrentAccount currentAccount1 = new CurrentAccount("anon3", 56171, "18jun19", "bnglr", 70000, address3);
+ currentAccount1.getAccDetails();
+ }
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 1/ContractEmployee.class b/Week 3 Assignment 1/ContractEmployee.class
new file mode 100644
index 0000000..a7ee906
Binary files /dev/null and b/Week 3 Assignment 1/ContractEmployee.class differ
diff --git a/Week 3 Assignment 1/CurrentAccount.class b/Week 3 Assignment 1/CurrentAccount.class
new file mode 100644
index 0000000..9a85a6b
Binary files /dev/null and b/Week 3 Assignment 1/CurrentAccount.class differ
diff --git a/Week 3 Assignment 1/Employee.class b/Week 3 Assignment 1/Employee.class
new file mode 100644
index 0000000..42cfe08
Binary files /dev/null and b/Week 3 Assignment 1/Employee.class differ
diff --git a/Week 3 Assignment 1/EmployeeClient.class b/Week 3 Assignment 1/EmployeeClient.class
new file mode 100644
index 0000000..378b0cf
Binary files /dev/null and b/Week 3 Assignment 1/EmployeeClient.class differ
diff --git a/Week 3 Assignment 1/EmployeeClient_W3A1_1.java b/Week 3 Assignment 1/EmployeeClient_W3A1_1.java
new file mode 100644
index 0000000..ec3f2b4
--- /dev/null
+++ b/Week 3 Assignment 1/EmployeeClient_W3A1_1.java
@@ -0,0 +1,115 @@
+import java.util.Arrays;
+
+abstract class Employee {
+ public int id;
+ public String name;
+ public int age;
+ public String projectName;
+ public boolean applyLeave = false;
+ public String[] skills;
+
+ Employee(int id, String name, int age, String projectName, String[] skills) {
+ this.id = id;
+ this.name = name;
+ this.age = age;
+ this.projectName = projectName;
+ this.skills = skills;
+ }
+ public abstract boolean canApplyLeave(int duration);
+ public abstract void getEmployeeDetails();
+}
+
+class RegularEmployee extends Employee {
+ private static int leaveBalance = 20; //days
+ private static double fixedSalary;
+ private static double bonus;
+
+ RegularEmployee(int id, String name, int age, String projectName, String[] skills, double fixedSalary, double bonus) {
+ super(id, name, age, projectName, skills);
+ this.fixedSalary = fixedSalary;
+ this.bonus = bonus;
+ }
+
+ @Override
+ public boolean canApplyLeave(int duration) {
+ if(leaveBalance > duration) {
+ applyLeave = true;
+ leaveBalance -= duration;
+ }
+ return applyLeave;
+ }
+
+ public int getLeaveBalance() {
+ return leaveBalance;
+ }
+
+ public void getEmployeeDetails() {
+ System.out.println(
+ "Employee ID: " + id +
+ "\nEmployee Name: " + name +
+ "\nEmployee age: " + age +
+ "\nProject name: " + projectName +
+ "\nSkills: " + Arrays.toString(skills) +
+ "\nBonus: " + bonus +
+ "\nLeave Balance: " + leaveBalance
+ );
+ }
+}
+
+class ContractEmployee extends Employee {
+ private static int contractDuration = 60; //days
+ private static double payPerHour;
+
+ ContractEmployee(int id, String name, int age, String projectName, String[] skills, double payPerHour) {
+ super(id, name, age, projectName, skills);
+ this.payPerHour = payPerHour;
+ }
+
+ @Override
+ public boolean canApplyLeave(int duration) {
+ if(contractDuration > duration) {
+ applyLeave = true;
+ contractDuration += duration;
+ }
+ return applyLeave;
+ }
+
+ public int getRemainingContractDuration() {
+ return contractDuration;
+ }
+
+ @Override
+ public void getEmployeeDetails() {
+ System.out.println(
+ "Employee ID: " + id +
+ "\nEmployee Name: " + name +
+ "\nEmployee age: " + age +
+ "\nProject name: " + projectName +
+ "\nSkills: " + Arrays.toString(skills) +
+ "\nPay per hour: " + payPerHour +
+ "\nRemaining contract period days: " + contractDuration + " days"
+ );
+ }
+}
+
+public class EmployeeClient_W3A1_1 {
+ public static void main(String args[]) {
+ String emp1Skills[] = {"Java", "Spring", "JS", "Shell scripting"};
+ RegularEmployee regEmp1 = new RegularEmployee(12, "anon1", 34, "prism", emp1Skills, 340000, 20000);
+ System.out.println(regEmp1.canApplyLeave(12));
+ System.out.println(regEmp1.getLeaveBalance());
+ regEmp1.getEmployeeDetails();
+ if(regEmp1.canApplyLeave(5)) {
+ System.out.println("New leave balance: " + regEmp1.getLeaveBalance());
+ }
+
+ System.out.println();
+
+ String contractEmp1Skills[] = {"Pen testing", "Network Security", "Data analysis"};
+ ContractEmployee contractEmp1 = new ContractEmployee(29, "anon2", 29, "ufo", contractEmp1Skills, 10);
+ if(contractEmp1.canApplyLeave(13)) {
+ System.out.println("Your new contract period: " + contractEmp1.getRemainingContractDuration() + " days");
+ }
+ contractEmp1.getEmployeeDetails();
+ }
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 1/MainClass.class b/Week 3 Assignment 1/MainClass.class
new file mode 100644
index 0000000..7754277
Binary files /dev/null and b/Week 3 Assignment 1/MainClass.class differ
diff --git a/Week 3 Assignment 1/RegularEmployee.class b/Week 3 Assignment 1/RegularEmployee.class
new file mode 100644
index 0000000..4165ab9
Binary files /dev/null and b/Week 3 Assignment 1/RegularEmployee.class differ
diff --git a/Week 3 Assignment 1/SalariedAccount.class b/Week 3 Assignment 1/SalariedAccount.class
new file mode 100644
index 0000000..8033ef8
Binary files /dev/null and b/Week 3 Assignment 1/SalariedAccount.class differ
diff --git a/Week 3 Assignment 1/SavingsAccount.class b/Week 3 Assignment 1/SavingsAccount.class
new file mode 100644
index 0000000..3274ad4
Binary files /dev/null and b/Week 3 Assignment 1/SavingsAccount.class differ
diff --git a/Week 3 Assignment 1/accountRules.class b/Week 3 Assignment 1/accountRules.class
new file mode 100644
index 0000000..b4c57b2
Binary files /dev/null and b/Week 3 Assignment 1/accountRules.class differ
diff --git a/Week 3 Assignment 2/Cart.class b/Week 3 Assignment 2/Cart.class
new file mode 100644
index 0000000..cde57a8
Binary files /dev/null and b/Week 3 Assignment 2/Cart.class differ
diff --git a/Week 3 Assignment 2/Catalogue.class b/Week 3 Assignment 2/Catalogue.class
new file mode 100644
index 0000000..7b35027
Binary files /dev/null and b/Week 3 Assignment 2/Catalogue.class differ
diff --git a/Week 3 Assignment 2/Category.class b/Week 3 Assignment 2/Category.class
new file mode 100644
index 0000000..4d98f94
Binary files /dev/null and b/Week 3 Assignment 2/Category.class differ
diff --git a/Week 3 Assignment 2/Checkout.class b/Week 3 Assignment 2/Checkout.class
new file mode 100644
index 0000000..f3742f6
Binary files /dev/null and b/Week 3 Assignment 2/Checkout.class differ
diff --git a/Week 3 Assignment 2/Ecommerce.java b/Week 3 Assignment 2/Ecommerce.java
new file mode 100644
index 0000000..f29249b
--- /dev/null
+++ b/Week 3 Assignment 2/Ecommerce.java
@@ -0,0 +1,206 @@
+import java.util.Collections;
+import java.util.Arrays;
+
+abstract class Item {
+ public int itemId;
+ public String itemName;
+ public String itemDesc;
+ public double itemPrice;
+
+ public Item(int itemId, String itemName, String itemDesc, double itemPrice) {
+ this.itemId = itemId;
+ this.itemName = itemName;
+ this.itemDesc = itemDesc;
+ this.itemPrice = itemPrice;
+ }
+ abstract int getItem();
+ abstract double getPrice();
+}
+
+class Mobile extends Item {
+ public Mobile(int itemId, String itemName, String itemDesc, double itemPrice) {
+ super(itemId, itemName, itemDesc, itemPrice);
+ }
+
+ @Override
+ public int getItem() {
+ return this.itemId;
+ }
+
+ @Override
+ public double getPrice() {
+ return this.itemPrice;
+ }
+}
+
+class Fashion extends Item {
+ public Fashion(int itemId, String itemName, String itemDesc, double itemPrice) {
+ super(itemId, itemName, itemDesc, itemPrice);
+ }
+
+ @Override
+ public int getItem() {
+ return this.itemId;
+ }
+
+ @Override
+ public double getPrice() {
+ return this.itemPrice;
+ }
+}
+
+class Seller {
+ private static int itemCount = 0;
+ private Object[] items;
+
+ private int sellerId;
+ private String sellerName;
+ private String sellerAddress;
+ private long sellerContactDetails;
+
+ public Seller(int sellerId, String sellerName, String sellerAddress, long sellerContactDetails) {
+ this.sellerId = sellerId;
+ this.sellerName = sellerName;
+ this.sellerAddress = sellerAddress;
+ this.sellerContactDetails = sellerContactDetails;
+ }
+
+ public void sellItems(Object ...obj) {
+ this.items = obj;
+ itemCount = items.length;
+ }
+ public int getItemCount() {
+ return items.length;
+ }
+}
+
+class User {
+ private int userId;
+ private String userName;
+ private String userAddress;
+ private long userContactDetails;
+
+ public User(int userId, String userName, String userAddress, long userContactDetails) {
+ this.userId = userId;
+ this.userName = userName;
+ this.userAddress = userAddress;
+ this.userContactDetails = userContactDetails;
+ }
+
+ public String getUserName() {
+ return this.userName;
+ }
+}
+
+class Cart {
+ public Object user;
+ public int quantity;
+ public Object item;
+
+ public Cart() {};
+
+ public Cart(Object user, int quantity, Object item) {
+ this.user = user;
+ this.quantity = quantity;
+ this.item = item;
+ }
+ public Object getItem() {
+ return this.item;
+ }
+ public int getQuantity() {
+ return this.quantity;
+ }
+ public Object getUser() {
+ return this.user;
+ }
+}
+
+class Checkout extends Cart {
+ private int noOfItems = 0;
+ private double price;
+ private String userName;
+ private double total = 0;
+ public void checkoutCartItems(Cart ...carts) {
+ for(int i = 0; i < carts.length; i++) {
+ if(carts[i].getItem() instanceof Mobile) {
+ Mobile mob = (Mobile)carts[i].getItem();
+ User user = (User)carts[i].getUser();
+ this.noOfItems = carts[i].getQuantity();
+ this.price = getItemPrice(mob);
+ this.userName = getUserName(user);
+ calacTotal();
+ }
+ else if(carts[i].getItem() instanceof Fashion) {
+ Fashion fash = (Fashion)carts[i].getItem();
+ User user = (User)carts[i].getUser();
+ this.noOfItems = carts[i].getQuantity();
+ this.price = getItemPrice(fash);
+ this.userName = getUserName(user);
+ calacTotal();
+ }
+ }
+ }
+
+ private double getItemPrice(Mobile mobile) {
+ return mobile.getPrice();
+ }
+
+ private double getItemPrice(Fashion fashion) {
+ return fashion.getPrice();
+ }
+
+ private String getUserName(User user) {
+ return user.getUserName();
+ }
+ private void calacTotal() {
+ total = total + (price * noOfItems);
+ }
+ public double getTotalPrice() {
+ return total;
+ }
+}
+
+interface PaymentTypes {
+ void payWithDebit();
+ void payWithCredit();
+ void payWithNetBanking();
+ void payWithWallet();
+}
+
+class Payment extends Checkout implements PaymentTypes {
+ private double price;
+ private int orderId;
+
+ public Payment(Checkout price) {
+ //generating random numbers
+ String[] arr = {"1","2","3","4","5","6","7","8","9","0"};
+ Collections.shuffle(Arrays.asList(arr));
+ StringBuilder stringBuilder = new StringBuilder();
+ for(String letter: arr) {
+ stringBuilder.append(letter);
+ }
+ orderId = Integer.parseInt(stringBuilder.toString().substring(0, 6));
+ System.out.println("Order ID: " + orderId);
+ this.price = price.getTotalPrice();
+ }
+
+ @Override
+ public void payWithDebit() {
+ System.out.println("Paid " + this.price + " using Debit card");
+ }
+
+ @Override
+ public void payWithCredit() {
+ System.out.println("Paid " + this.price + " using Credit card");
+ }
+
+ @Override
+ public void payWithNetBanking() {
+ System.out.println("Paid " + this.price + " using Net banking");
+ }
+
+ @Override
+ public void payWithWallet() {
+ System.out.println("Paid " + this.price + " using Wallet");
+ }
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 2/EcommerceClient.class b/Week 3 Assignment 2/EcommerceClient.class
new file mode 100644
index 0000000..8a0fb4b
Binary files /dev/null and b/Week 3 Assignment 2/EcommerceClient.class differ
diff --git a/Week 3 Assignment 2/EcommerceClient.java b/Week 3 Assignment 2/EcommerceClient.java
new file mode 100644
index 0000000..53eb17c
--- /dev/null
+++ b/Week 3 Assignment 2/EcommerceClient.java
@@ -0,0 +1,28 @@
+public class EcommerceClient {
+ public static void main(String args[]) {
+ /**
+ * Life cycle of an item
+ * add item[1] -> assign items to seller[2] -> user selects items and adds to cart[3] -> checkout/payment[4]
+ */
+ Mobile nokia1100 = new Mobile(123, "Nokia 1100", "first M item", 500); //[1]
+ Mobile onePlus = new Mobile(156, "OnePlus 7 Pro", "second M item", 600); //[1]
+ Fashion suit = new Fashion(245, "Black suit", "first F item", 300); //[1]
+ Fashion tie = new Fashion(287, "Grey Tie", "second F item", 100); //[1]
+
+ Seller seller1 = new Seller(757, "seller1", "selleraddress1", 7881992310L);
+ seller1.sellItems(nokia1100, onePlus, suit, tie); //[2]
+
+ User user1 = new User(984, "user1", "useraddress1", 9981998110L); //new user
+
+ //Cart(user's object, quantity, item)
+ Cart cart1 = new Cart(user1, 2, nokia1100); //[3]
+ Cart cart2 = new Cart(user1, 1, onePlus); //[3]
+ Cart cart3 = new Cart(user1, 1, suit); //[3]
+
+ Checkout checkout = new Checkout();
+ checkout.checkoutCartItems(cart1, cart2, cart3); //[4]
+ System.out.println("Total price: " + checkout.getTotalPrice()); //total price
+ Payment payment = new Payment(checkout);
+ payment.payWithNetBanking(); //[4]
+ }
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 2/Fashion.class b/Week 3 Assignment 2/Fashion.class
new file mode 100644
index 0000000..29bc3c2
Binary files /dev/null and b/Week 3 Assignment 2/Fashion.class differ
diff --git a/Week 3 Assignment 2/Item.class b/Week 3 Assignment 2/Item.class
new file mode 100644
index 0000000..bb7e0f7
Binary files /dev/null and b/Week 3 Assignment 2/Item.class differ
diff --git a/Week 3 Assignment 2/Mobile.class b/Week 3 Assignment 2/Mobile.class
new file mode 100644
index 0000000..dcf0861
Binary files /dev/null and b/Week 3 Assignment 2/Mobile.class differ
diff --git a/Week 3 Assignment 2/Payment.class b/Week 3 Assignment 2/Payment.class
new file mode 100644
index 0000000..f754522
Binary files /dev/null and b/Week 3 Assignment 2/Payment.class differ
diff --git a/Week 3 Assignment 2/PaymentTypes.class b/Week 3 Assignment 2/PaymentTypes.class
new file mode 100644
index 0000000..369c8c3
Binary files /dev/null and b/Week 3 Assignment 2/PaymentTypes.class differ
diff --git a/Week 3 Assignment 2/Seller.class b/Week 3 Assignment 2/Seller.class
new file mode 100644
index 0000000..da60e84
Binary files /dev/null and b/Week 3 Assignment 2/Seller.class differ
diff --git a/Week 3 Assignment 2/User.class b/Week 3 Assignment 2/User.class
new file mode 100644
index 0000000..d949839
Binary files /dev/null and b/Week 3 Assignment 2/User.class differ
diff --git a/Week 3 Assignment 3/SelfDrive.java b/Week 3 Assignment 3/SelfDrive.java
new file mode 100644
index 0000000..50c4eeb
--- /dev/null
+++ b/Week 3 Assignment 3/SelfDrive.java
@@ -0,0 +1,24 @@
+interface selfDriveVehicles {
+ void drive(int option);
+}
+
+class VehicleType implements selfDriveVehicles {
+
+ private String source;
+ private String destination;
+ public VehicleType(String source, String destination) {
+ this.source = source;
+ this.destination = destination;
+ }
+
+ @Override
+ public void drive(int option) {
+ if(option == 1) {
+ System.out.println("You have chosen WagonR to drive from " + this.source + " to " + this.destination);
+ }
+ else if(option == 2) {
+ System.out.println("You have chosen BMW to drive from " + this.source + " to " + this.destination);
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 3/SelfDriveClient.java b/Week 3 Assignment 3/SelfDriveClient.java
new file mode 100644
index 0000000..6f617ce
--- /dev/null
+++ b/Week 3 Assignment 3/SelfDriveClient.java
@@ -0,0 +1,6 @@
+public class SelfDriveClient {
+ public static void main(String args[]) {
+ VehicleType efficiency = new VehicleType("Silk Board", "Electronic City");
+ efficiency.drive(1);
+ }
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 3/Vehicle.java b/Week 3 Assignment 3/Vehicle.java
new file mode 100644
index 0000000..2d6a334
--- /dev/null
+++ b/Week 3 Assignment 3/Vehicle.java
@@ -0,0 +1,129 @@
+abstract class Vehicle {
+
+ public String vehicleRegNo;
+ public int vehicleMake;
+ public String vehicleModel;
+ public String vehicleColor;
+
+ public Vehicle(String vehicleRegNo, int vehicleMake, String vehicleModel, String vehicleColor) {
+ this.vehicleRegNo = vehicleRegNo;
+ this.vehicleMake = vehicleMake;
+ this.vehicleModel = vehicleModel;
+ this.vehicleColor = vehicleColor;
+ }
+
+}
+
+abstract class Goods extends Vehicle {
+
+ public Goods(String vehicleRegNo, int vehicleMake, String vehicleModel, String vehicleColor) {
+ super(vehicleRegNo, vehicleMake, vehicleModel, vehicleColor);
+ }
+
+ abstract public void vehicleSpecialty();
+ abstract public void setGoodsWeight(double goodsWeight);
+}
+
+abstract class Passenger extends Vehicle {
+
+ private int noOfPassengers;
+ public Passenger(String vehicleRegNo, int vehicleMake, String vehicleModel, String vehicleColor, int noOfPassengers) {
+ super(vehicleRegNo, vehicleMake, vehicleModel, vehicleColor);
+ this.noOfPassengers = noOfPassengers;
+ }
+ abstract public void vehicleSpecialty();
+ abstract public void setPassengers(int num);
+
+}
+
+class GoodVehicle extends Goods {
+
+ private double goodsWeight = 500; //in kilograms
+ public GoodVehicle(String vehicleRegNo, int vehicleMake, String vehicleModel, String vehicleColor, double goodsWeight) {
+ super(vehicleRegNo, vehicleMake, vehicleModel, vehicleColor);
+ this.goodsWeight = goodsWeight;
+ }
+
+ @Override
+ public void vehicleSpecialty() {
+ System.out.println("Can carry goods over " + this.goodsWeight + " KGs");
+ }
+
+ @Override
+ public void setGoodsWeight(double goodsWeight) {
+ this.goodsWeight = goodsWeight;
+ }
+
+}
+
+class PassengerVehicle extends Passenger {
+
+ private int noOfPassengers = 4;
+ public PassengerVehicle(String vehicleRegNo, int vehicleMake, String vehicleModel, String vehicleColor, int noOfPassengers) {
+ super(vehicleRegNo, vehicleMake, vehicleModel, vehicleColor, noOfPassengers);
+ this.noOfPassengers = noOfPassengers;
+ }
+
+ @Override
+ public void vehicleSpecialty() {
+ System.out.println("Passenger vehicle can carry " + this.noOfPassengers + " passengers");
+ }
+
+ @Override
+ public void setPassengers(int noOfPassengers) {
+ if(noOfPassengers <= 6 ) {
+ this.noOfPassengers = noOfPassengers;
+ }
+ else System.out.println("Passenger cars cannot carry more than 6 passengers");
+ }
+
+}
+
+class LuxuryVehicle extends Passenger {
+
+ private int noOfPassengers = 2;
+ public LuxuryVehicle(String vehicleRegNo, int vehicleMake, String vehicleModel, String vehicleColor, int noOfPassengers) {
+ super(vehicleRegNo, vehicleMake, vehicleModel, vehicleColor, noOfPassengers);
+ this.noOfPassengers = noOfPassengers;
+ }
+
+ @Override
+ public void vehicleSpecialty() {
+ System.out.println("Luxury vehicle can carry " + this.noOfPassengers + " passengers");
+ }
+
+ @Override
+ public void setPassengers(int noOfPassengers) {
+ if(noOfPassengers <= 2) {
+ this.noOfPassengers = noOfPassengers;
+ }
+ else System.out.println("Luxury cars cannot carry more than 2 passengers");
+ }
+
+}
+
+class RacingVehicle extends Passenger {
+
+ private final int NO_OF_PASSENGERS = 1;
+ public RacingVehicle(String vehicleRegNo, int vehicleMake, String vehicleModel, String vehicleColor,
+ int NO_OF_PASSENGERS) {
+ super(vehicleRegNo, vehicleMake, vehicleModel, vehicleColor, NO_OF_PASSENGERS);
+ if(NO_OF_PASSENGERS != 1) {
+ System.out.println("Racing vehicles cannot carry more than 1 passenger");
+ }
+
+ }
+
+ @Override
+ public void vehicleSpecialty() {
+ System.out.println("Racong vehicle can carry " + this.NO_OF_PASSENGERS + " passenger");
+ }
+
+ @Override
+ public void setPassengers(int NO_OF_PASSENGERS) {
+ if(NO_OF_PASSENGERS != 1) {
+ System.out.println("Racing vehicles cannot carry more than 1 passenger");
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Week 3 Assignment 3/VehicleClient.java b/Week 3 Assignment 3/VehicleClient.java
new file mode 100644
index 0000000..5bc4f4f
--- /dev/null
+++ b/Week 3 Assignment 3/VehicleClient.java
@@ -0,0 +1,14 @@
+public class VehicleClient {
+ public static void main(String args[]) {
+ Passenger passengerVehicleSwift = new PassengerVehicle("KA 05 ME 8619", 2018, "Swift", "Red", 3);
+ passengerVehicleSwift.vehicleSpecialty();
+
+ passengerVehicleSwift.setPassengers(4);
+ passengerVehicleSwift.vehicleSpecialty();
+
+ passengerVehicleSwift.setPassengers(7);
+
+ Goods goodsVehicle1 = new GoodVehicle("KA 51 AB 7812", 2014, "Ace", "Grey", 400);
+ goodsVehicle1.vehicleSpecialty();
+ }
+}
\ No newline at end of file
diff --git a/Week 4 Assignment 1/.classpath b/Week 4 Assignment 1/.classpath
new file mode 100644
index 0000000..fb50116
--- /dev/null
+++ b/Week 4 Assignment 1/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/Week 4 Assignment 1/.gitignore b/Week 4 Assignment 1/.gitignore
new file mode 100644
index 0000000..ae3c172
--- /dev/null
+++ b/Week 4 Assignment 1/.gitignore
@@ -0,0 +1 @@
+/bin/
diff --git a/Week 4 Assignment 1/.project b/Week 4 Assignment 1/.project
new file mode 100644
index 0000000..fead765
--- /dev/null
+++ b/Week 4 Assignment 1/.project
@@ -0,0 +1,17 @@
+
+
+ Week 4 Assignment 1
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/Week 4 Assignment 1/src/com/greatlearning/fsd/module4/exceptions/InvalidAmountException.java b/Week 4 Assignment 1/src/com/greatlearning/fsd/module4/exceptions/InvalidAmountException.java
new file mode 100644
index 0000000..2578648
--- /dev/null
+++ b/Week 4 Assignment 1/src/com/greatlearning/fsd/module4/exceptions/InvalidAmountException.java
@@ -0,0 +1,5 @@
+package com.greatlearning.fsd.module4.exceptions;
+
+public class InvalidAmountException {
+
+}
diff --git a/Week 4 Assignment 1/src/com/week4/restaurant/controller/Restaurant.java b/Week 4 Assignment 1/src/com/week4/restaurant/controller/Restaurant.java
new file mode 100644
index 0000000..1915dec
--- /dev/null
+++ b/Week 4 Assignment 1/src/com/week4/restaurant/controller/Restaurant.java
@@ -0,0 +1,70 @@
+package com.week4.restaurant.controller;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Scanner;
+
+import com.week4.restaurant.model.Dish;
+
+public class Restaurant {
+ public static void main(String args[]) {
+
+ Scanner scans = new Scanner(System.in);
+ List dishesList = new ArrayList<>();
+
+ dishesList.add(new Dish(5, "Neer-Dosa", 50, 100));
+ dishesList.add(new Dish(10, "dish2", 500, 50));
+ dishesList.add(new Dish(4, "dish3", 350, 30));
+ dishesList.add(new Dish(3, "dish3", 250, 58));
+
+ System.out.println("=================Welcome=====================");
+ System.out.println("Please choose from the below options");
+ System.out.println("1 => To sort the dishes in the increasing order of calories"
+ + "\n2 => To sort the dishes in the decreasing order of calories"
+ + "\n3 => To sort the dishes in the increasing order of price"
+ + "\n4 => To sort the dishes in the decreasing order of price");
+
+ int userChoice = scans.nextInt();
+ switch(userChoice) {
+ case 1:
+ Comparator compareByIncCalories = (Dish o1, Dish o2) -> o1.getCalories().compareTo(o2.getCalories());
+ Collections.sort(dishesList, compareByIncCalories);
+ for (Dish s : dishesList) {
+ System.out.println(s.toString());
+ }
+ break;
+
+ case 2:
+ Comparator compareByDecCalories = (Dish o1, Dish o2) -> o1.getCalories().compareTo(o2.getCalories());
+ Collections.sort(dishesList, compareByDecCalories);
+ Collections.reverse(dishesList);
+ for (Dish s : dishesList) {
+ System.out.println(s.toString());
+ }
+ break;
+
+ case 3:
+ Comparator compareByIncPrice = (Dish o1, Dish o2) -> o1.getPrice().compareTo(o2.getPrice());
+ Collections.sort(dishesList, compareByIncPrice);
+ for (Dish s : dishesList) {
+ System.out.println(s.toString());
+ }
+ break;
+
+ case 4:
+ Comparator compareByDecPrice = (Dish o1, Dish o2) -> o1.getPrice().compareTo(o2.getPrice());
+ Collections.sort(dishesList, compareByDecPrice);
+ Collections.reverse(dishesList);
+ for (Dish s : dishesList) {
+ System.out.println(s.toString());
+ }
+ break;
+
+ default:
+ System.out.println("Please choose an option between 1 and 4");
+ break;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Week 4 Assignment 1/src/com/week4/restaurant/model/Dish.java b/Week 4 Assignment 1/src/com/week4/restaurant/model/Dish.java
new file mode 100644
index 0000000..48b1223
--- /dev/null
+++ b/Week 4 Assignment 1/src/com/week4/restaurant/model/Dish.java
@@ -0,0 +1,112 @@
+package com.week4.restaurant.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Dish implements Comparable {
+ private int id;
+ private String name;
+ public enum dishType {
+ Veg,
+ Non_Veg
+ }
+ private double calories;
+ private double price;
+ private List dishes = new ArrayList<>();
+
+ public Dish(int id, String name, double price, double calories) {
+ this.id = id;
+ this.name = name;
+ this.price = price;
+ this.calories = calories;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public void setId(int id) {
+ this.id = id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Double getCalories() {
+ return calories;
+ }
+
+ public void setCalories(double calories) {
+ this.calories = calories;
+ }
+
+ public Double getPrice() {
+ return price;
+ }
+
+ public void setPrice(double price) {
+ this.price = price;
+ }
+
+ public List getDishes() {
+ return dishes;
+ }
+
+ public void setDishes(List dishes) {
+ this.dishes = dishes;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ long temp;
+
+ temp = Double.doubleToLongBits(calories);
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ result = prime * result + id;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ temp = Double.doubleToLongBits(price);
+
+ result = prime * result + (int) (temp ^ (temp >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Dish other = (Dish) obj;
+ if (Double.doubleToLongBits(calories) != Double.doubleToLongBits(other.calories))
+ return false;
+ if (id != other.id)
+ return false;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ if (Double.doubleToLongBits(price) != Double.doubleToLongBits(other.price))
+ return false;
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ return "Dish [id=" + id + ", name=" + name + ", calories=" + calories + ", price=" + price + "]";
+ }
+
+ @Override
+ public int compareTo(Dish o) {
+ return this.getCalories().compareTo(o.getCalories());
+ }
+}
\ No newline at end of file
diff --git a/Week 4 Assignment 1/src/com/week4/restaurant/model/Order.java b/Week 4 Assignment 1/src/com/week4/restaurant/model/Order.java
new file mode 100644
index 0000000..ce23e56
--- /dev/null
+++ b/Week 4 Assignment 1/src/com/week4/restaurant/model/Order.java
@@ -0,0 +1,5 @@
+package com.week4.restaurant.model;
+
+public class Order {
+
+}
diff --git a/Week 4 Assignment 1/src/com/week4/restaurant/model/VegType.java b/Week 4 Assignment 1/src/com/week4/restaurant/model/VegType.java
new file mode 100644
index 0000000..99002c8
--- /dev/null
+++ b/Week 4 Assignment 1/src/com/week4/restaurant/model/VegType.java
@@ -0,0 +1,5 @@
+package com.week4.restaurant.model;
+
+public class VegType {
+
+}
diff --git a/Week 5 Assignment 1/.classpath b/Week 5 Assignment 1/.classpath
new file mode 100644
index 0000000..fb50116
--- /dev/null
+++ b/Week 5 Assignment 1/.classpath
@@ -0,0 +1,6 @@
+
+
+
+
+
+
diff --git a/Week 5 Assignment 1/.project b/Week 5 Assignment 1/.project
new file mode 100644
index 0000000..b6cbcb5
--- /dev/null
+++ b/Week 5 Assignment 1/.project
@@ -0,0 +1,17 @@
+
+
+ fsd-twitter-java-master
+
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/client/Client.class b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/client/Client.class
new file mode 100644
index 0000000..0ad256b
Binary files /dev/null and b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/client/Client.class differ
diff --git a/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/Tweet$Stats.class b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/Tweet$Stats.class
new file mode 100644
index 0000000..a50afcf
Binary files /dev/null and b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/Tweet$Stats.class differ
diff --git a/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/Tweet.class b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/Tweet.class
new file mode 100644
index 0000000..a0c5625
Binary files /dev/null and b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/Tweet.class differ
diff --git a/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/User$Role.class b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/User$Role.class
new file mode 100644
index 0000000..94ed375
Binary files /dev/null and b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/User$Role.class differ
diff --git a/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/User.class b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/User.class
new file mode 100644
index 0000000..77d5ab0
Binary files /dev/null and b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/model/User.class differ
diff --git a/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/service/UserService.class b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/service/UserService.class
new file mode 100644
index 0000000..8cd212e
Binary files /dev/null and b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/service/UserService.class differ
diff --git a/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/service/UserServiceImpl.class b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/service/UserServiceImpl.class
new file mode 100644
index 0000000..44a68f7
Binary files /dev/null and b/Week 5 Assignment 1/bin/com/greatlearning/fsd/twitter/service/UserServiceImpl.class differ
diff --git a/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/client/Client.java b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/client/Client.java
new file mode 100644
index 0000000..1723a41
--- /dev/null
+++ b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/client/Client.java
@@ -0,0 +1,117 @@
+package com.greatlearning.fsd.twitter.client;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Scanner;
+import java.util.Set;
+
+import com.greatlearning.fsd.twitter.model.Tweet;
+import com.greatlearning.fsd.twitter.model.User;
+import com.greatlearning.fsd.twitter.service.UserService;
+import com.greatlearning.fsd.twitter.service.UserServiceImpl;
+
+public class Client {
+
+ public static void main(String[] args) {
+
+ UserService userService = UserServiceImpl.getInstance();
+ Set users = populateData(userService);
+ Scanner scans = new Scanner(System.in);
+
+ System.out.println();
+ printEntitySet(users);
+
+ int userInput;
+ System.out.println("========== Tweet Interface =========");
+ System.out.println("1 => Post a tweet");
+ System.out.println("2 => View external tweet feed");
+ System.out.println("3 => View my tweets");
+ System.out.println("4 => Like a tweet");
+ System.out.println("5 => Comment on a tweet");
+ System.out.println("====================================");
+ userInput = scans.nextInt();
+
+ switch(userInput) {
+ case 1:
+ System.out.println("User name: ");
+ String userName = scans.nextLine();
+ String userTweet = scans.nextLine();
+ new Tweet(userName, userTweet);
+ break;
+ case 2:
+ System.out.println("Twitter feed\n");
+ Iterator it = users.iterator();
+ while(it.hasNext()){
+ User user = it.next();
+ if(!user.getTweets().isEmpty()) {
+ System.out.println("Tweets by User - " + user.getFirstName());
+ printEntitySet(userService.fetchTweetsByUser(user.getId()));
+ }
+ }
+ break;
+ case 3:
+ System.out.println("View my tweets");
+ Iterator it1 = users.iterator();
+ while(it1.hasNext()){
+ User user = it1.next();
+ if(!user.getTweets().isEmpty()) {
+ System.out.println("My tweets" + user.getFirstName());
+ printEntitySet(userService.fetchTweetsByUser(user.getId()));
+ }
+ }
+ break;
+ case 4:
+ int i = 1;
+ Tweet tweet;
+ System.out.println("Like a tweet: ");
+ Iterator it11 = users.iterator();
+ while(it11.hasNext()){
+ User user = it11.next();
+ if(!user.getTweets().isEmpty()) {
+ System.out.println(i + " " + user.getFirstName());
+ printEntitySet(userService.fetchTweetsByUser(user.getId()));
+ }
+ i++;
+ }
+ System.out.println("Select a tweet: ");
+ int tweetChoice = scans.nextInt();
+ Tweet.Stats.setLikes(1);
+ break;
+ case 5:
+ System.out.println("Comment on a tweet: ");
+ Iterator it12 = users.iterator();
+ while(it12.hasNext()){
+ User user = it12.next();
+ if(!user.getTweets().isEmpty()) {
+ System.out.println(user.getFirstName());
+ printEntitySet(userService.fetchTweetsByUser(user.getId()));
+ }
+ }
+ System.out.println("Select a tweet: ");
+ int tweetComment = scans.nextInt();
+ System.out.println("write a comment below: ");
+ String comment = scans.nextLine();
+ Tweet.Stats.setComments(1);
+ }
+ }
+
+ private static Set populateData(UserService userService) {
+ Set userSet = new HashSet<>();
+ User user1 = userService.createUser( "user_1", "Firstname1", "Lastname1", "user1@gmail.com");
+ User user2 = userService.createUser( "user_2", "Firstname2", "Lastname2", "user2@gmail.com");
+
+ Tweet tweet1 = new Tweet("Tweet 1");
+ Tweet tweet2 = new Tweet("Tweet 2");
+
+ userSet.add(user1);
+ userSet.add(user2);
+ return userSet;
+ }
+
+ private static void printEntitySet(Set entity ){
+ Iterator it = entity.iterator();
+ while(it.hasNext()){
+ System.out.println(it.next());
+ }
+ }
+}
\ No newline at end of file
diff --git a/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/model/Tweet.java b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/model/Tweet.java
new file mode 100644
index 0000000..b112f57
--- /dev/null
+++ b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/model/Tweet.java
@@ -0,0 +1,108 @@
+package com.greatlearning.fsd.twitter.model;
+
+import java.util.Date;
+import java.util.Objects;
+
+public class Tweet {
+ private final long id;
+ private String tweetMessage;
+ private final String mediaUrl;
+ private final Date createdDt;
+ private static int idCounter = 100;
+
+ public static class Stats{
+ private static int likes;
+ private static int comments;
+ private int retweetCount;
+
+ public static int getLikes() {
+ return likes;
+ }
+
+ public static void setLikes(int like) {
+ likes = like;
+ }
+
+ public static int getComments() {
+ return comments;
+ }
+
+ public static void setComments(int comment) {
+ comments = comment;
+ }
+
+ public int getRetweetCount() {
+ return retweetCount;
+ }
+
+ public void setRetweetCount(int retweetCount) {
+ this.retweetCount = retweetCount;
+ }
+
+ @Override
+ public String toString() {
+ return "Stats{" +
+ "likes=" + likes +
+ ", comments=" + comments +
+ ", retweetCount=" + retweetCount +
+ '}';
+ }
+ }
+
+
+ public Tweet(String tweetMessage, String mediaUrl) {
+ this.id = ++idCounter;
+ this.tweetMessage = tweetMessage;
+ this.mediaUrl = mediaUrl;
+ this.createdDt = new Date();
+ }
+ public Tweet(String tweetMessage) {
+ this.id = ++idCounter;
+ this.tweetMessage = tweetMessage;
+ this.mediaUrl = null;
+ this.createdDt = new Date();
+ }
+
+ public long getId() {
+ return id;
+ }
+
+ public String getMessage() {
+ return tweetMessage;
+ }
+
+ public String getMediaUrl() {
+ return mediaUrl;
+ }
+
+ public Date getCreatedDt() {
+ return createdDt;
+ }
+
+ public static void setIdCounter(int idCounter) {
+ Tweet.idCounter = idCounter;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ Tweet tweet = (Tweet) o;
+ return id == tweet.id &&
+ Objects.equals(tweetMessage, tweet.tweetMessage) &&
+ Objects.equals(createdDt, tweet.createdDt);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, tweetMessage, createdDt);
+ }
+
+ @Override
+ public String toString() {
+ return "Tweet{" +
+ "tweetMessage='" + tweetMessage + '\'' +
+ ", mediaUrl='" + mediaUrl + '\'' +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/model/User.java b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/model/User.java
new file mode 100644
index 0000000..cd673c2
--- /dev/null
+++ b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/model/User.java
@@ -0,0 +1,179 @@
+package com.greatlearning.fsd.twitter.model;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Objects;
+import java.util.Set;
+
+public class User implements Comparable, Serializable {
+
+ public enum Role {
+ REGULAR_USER,
+ ADMIN
+ }
+
+ private final long id;
+ private final String userName;
+ private String profileImgUrl;
+ private String coverUrl;
+ private String password;
+ private String firstName;
+ private String lastName;
+ private final Role userRole;
+ private final String email;
+ //initial value
+ private static int userIdCount = 100;
+ private final Date createdDt;
+ private Date updatedDt;
+ private Set tweets = new HashSet<>();
+ private Set followers = new HashSet<>();
+ private Set following = new HashSet<>();
+
+ public User(String userName, String firstName, String lastName, String email){
+ this.id = ++ userIdCount;
+ this.userName = userName;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.email = email;
+ this.userRole = Role.REGULAR_USER;
+ this.createdDt = new Date();
+ this.updatedDt = new Date();
+
+ }
+ public User(String userName, String firstName, String lastName, String email, String profileImgUrl, String coverUrl){
+ this.id = ++ userIdCount;
+ this.userName = userName;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.email = email;
+ this.coverUrl = coverUrl;
+ this.profileImgUrl = profileImgUrl;
+ this.createdDt = new Date();
+ this.updatedDt = new Date();
+ this.userRole = Role.REGULAR_USER;
+ }
+
+
+ public long getId() {
+ return id;
+ }
+
+ public String getUserName() {
+ return userName;
+ }
+
+ public String getProfileImgUrl() {
+ return profileImgUrl;
+ }
+
+ public void setProfileImgUrl(String profileImgUrl) {
+ this.profileImgUrl = profileImgUrl;
+ }
+
+ public String getCoverUrl() {
+ return coverUrl;
+ }
+
+ public void setCoverUrl(String coverUrl) {
+ this.coverUrl = coverUrl;
+ }
+
+ public String getPassword() {
+ return password;
+ }
+
+ public void setPassword(String password) {
+ this.password = password;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public Role getUserRole() {
+ return userRole;
+ }
+
+ public String getEmail() {
+ return email;
+ }
+ public Date getCreatedDt() {
+ return createdDt;
+ }
+
+ public Date getUpdatedDt() {
+ return updatedDt;
+ }
+
+ public void setUpdatedDt(Date updatedDt) {
+ this.updatedDt = updatedDt;
+ }
+
+ public Set getTweets() {
+ return tweets;
+ }
+
+ public void addTweet(Tweet tweet){
+ this.tweets.add(tweet);
+ }
+
+ public Set getFollowers() {
+ return followers;
+ }
+
+ public void addFollower(User user){
+ this.followers.add(user);
+ }
+
+ public Set getFollowing() {
+ return following;
+ }
+
+ @Override
+ public int compareTo(User user) {
+ return Long.valueOf(this.id).compareTo(user.id);
+ }
+
+ @Override
+ public String toString() {
+ return "User{" +
+ "id=" + id +
+ ", userName='" + userName + '\'' +
+ ", profileImgUrl='" + profileImgUrl + '\'' +
+ ", coverUrl='" + coverUrl + '\'' +
+ ", firstName='" + firstName + '\'' +
+ ", lastName='" + lastName + '\'' +
+ ", userRole=" + userRole +
+ ", email='" + email + '\'' +
+ '}';
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ User user = (User) o;
+ return id == user.id &&
+ Objects.equals(userName, user.userName) &&
+ Objects.equals(email, user.email) &&
+ Objects.equals(createdDt, user.createdDt);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(id, userName, email, createdDt);
+ }
+}
\ No newline at end of file
diff --git a/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/service/UserService.java b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/service/UserService.java
new file mode 100644
index 0000000..feb33ab
--- /dev/null
+++ b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/service/UserService.java
@@ -0,0 +1,30 @@
+package com.greatlearning.fsd.twitter.service;
+
+import com.greatlearning.fsd.twitter.model.Tweet;
+import com.greatlearning.fsd.twitter.model.User;
+import java.util.Set;
+
+public interface UserService {
+
+ User createUser(String userName, String firstName, String lastName, String email);
+
+ User createUser(String userName, String firstName, String lastName, String email, String profileImgUrl, String coverUrl);
+
+ User updateUser(long userId, User user);
+
+ User findById(long userId);
+
+ void authenticateUser(String username, String password);
+
+ Set fetchTweetsByUser(long userId);
+
+ Set suggestUsers(long userId);
+
+ Set fetchFollowersByUserId(long userId);
+
+ User findUserByUserName(String userName);
+
+ void addFollower(long userId, User user);
+
+ Set fetchTweetsByFollowers(long userId);
+}
\ No newline at end of file
diff --git a/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/service/UserServiceImpl.java b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/service/UserServiceImpl.java
new file mode 100644
index 0000000..095cce6
--- /dev/null
+++ b/Week 5 Assignment 1/src/com/greatlearning/fsd/twitter/service/UserServiceImpl.java
@@ -0,0 +1,143 @@
+package com.greatlearning.fsd.twitter.service;
+
+import com.greatlearning.fsd.twitter.model.Tweet;
+import com.greatlearning.fsd.twitter.model.User;
+
+import java.util.*;
+
+public class UserServiceImpl implements UserService {
+
+ private static Map users = new HashMap<>();
+ private static UserServiceImpl userService = new UserServiceImpl();
+
+ private UserServiceImpl(){
+
+ }
+
+ public static UserServiceImpl getInstance(){
+ return userService;
+ }
+
+ @Override
+ public User createUser(String userName, String firstName, String lastName, String email) {
+ User user = new User(userName, firstName, lastName, email);
+ users.put(user.getId(), user);
+ return user;
+ }
+
+ @Override
+ public User createUser(String userName, String firstName, String lastName, String email, String profileImgUrl, String coverUrl) {
+ User user = new User(userName, firstName, lastName, email, profileImgUrl, coverUrl);
+ users.put(user.getId(), user);
+ return user;
+ }
+
+ @Override
+ public User updateUser(long userId, User user) {
+ User returnedUser = findById(userId);
+ if(returnedUser != null){
+ user.setUpdatedDt(new Date());
+ users.put(userId, user);
+ }
+ return returnedUser;
+ }
+
+ @Override
+ public User findById(long userId) {
+ return users.get(userId);
+ }
+
+ @Override
+ public void authenticateUser(String username, String password) {
+ User user = findUserByUserName(username);
+ if (user == null ){
+ throw new IllegalArgumentException("User does not exists");
+ }
+ if (! password.equals(user.getPassword())){
+ throw new IllegalArgumentException(" Username/password does not match");
+ }
+
+ }
+
+ @Override
+ public Set fetchTweetsByUser(long userId) {
+ User user = findById(userId);
+ if(user == null){
+ throw new IllegalArgumentException("Invalid User Id ");
+ }
+ return user.getTweets();
+ }
+
+ @Override
+ public Set suggestUsers(long userId) {
+ if(findById(userId) == null){
+ throw new IllegalArgumentException("Invalid User Id");
+ }
+ Set> entries = users.entrySet();
+ Set suggestedUsers = new HashSet<>();
+ Iterator> iterator = entries.iterator();
+ User selectedUser = null;
+ while (iterator.hasNext()){
+ Map.Entry entry = iterator.next();
+ long currentUserId = entry.getKey();
+ if(userId == currentUserId){
+ continue;
+ }
+ suggestedUsers.add(entry.getValue());
+
+ }
+ return suggestedUsers;
+ }
+
+ @Override
+ public Set fetchFollowersByUserId(long userId) {
+ User user = findById(userId);
+ if (user == null ){
+ throw new IllegalArgumentException("User does not exists");
+ }
+ return user.getFollowers();
+ }
+
+ @Override
+ public User findUserByUserName(String userName){
+ Set> entries = users.entrySet();
+ Iterator> iterator = entries.iterator();
+ User selectedUser = null;
+ while (iterator.hasNext()){
+ Map.Entry entry = iterator.next();
+ User user = entry.getValue();
+ if(user.getUserName().equals(userName)){
+ selectedUser = user;
+ break;
+ }
+ }
+ return selectedUser;
+ }
+
+ @Override
+ public void addFollower(long userId, User user) {
+ User fetchedUser = findById(userId);
+ if (fetchedUser == null ){
+ throw new IllegalArgumentException("User does not exists");
+ }
+ fetchedUser.addFollower(user);
+ }
+
+ @Override
+ public Set fetchTweetsByFollowers(long userId){
+ User fetchedUser = findById(userId);
+ Set tweetsByFollowers = new HashSet<>();
+ if (fetchedUser == null ){
+ throw new IllegalArgumentException("User does not exists");
+ }
+ Set followers = fetchedUser.getFollowers();
+ if (!followers.isEmpty()){
+ Iterator followersIt = followers.iterator();
+ while(followersIt.hasNext()){
+ User user = followersIt.next();
+ tweetsByFollowers.addAll(user.getTweets());
+ }
+ }
+ return tweetsByFollowers;
+ }
+}
\ No newline at end of file