commit 8e447756ac9ccc6a7ee2d71d565e1a5d49ee98cb Author: LinlyBoi Date: Thu Jan 27 19:21:54 2022 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..21b4487 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Project exclude paths +/out/ \ No newline at end of file diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..07115cd --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..006830e --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 0000000..e96534f --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/DeansBequest.iml b/DeansBequest.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/DeansBequest.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/Emploice/Employees.java b/src/Emploice/Employees.java new file mode 100644 index 0000000..32762ab --- /dev/null +++ b/src/Emploice/Employees.java @@ -0,0 +1,26 @@ +package Emploice; + +public class Employees +{ + String lastName; + String firstName; + double hourlyWage; + int yearsWithCompany; + public Employees() + { + + } + public Employees(int years) + { + this.yearsWithCompany = years; + } + @Override + public String toString() + { + return "First Name: " + firstName + "\nLast name: " + lastName + "\nHourly wage: " + hourlyWage + "\nYears with company: " + yearsWithCompany; + } + public int getYears() + { + return yearsWithCompany; + } +} diff --git a/src/Emploice/Programs.java b/src/Emploice/Programs.java new file mode 100644 index 0000000..e6eb7f1 --- /dev/null +++ b/src/Emploice/Programs.java @@ -0,0 +1,24 @@ +package Emploice; + +import java.util.Random; + +public class Programs +{ + public static void main(String[] args) + { + Employees[] employs = new Employees[100]; + + for(int j = 0; j < employs.length; j++) + { + Random r = new Random(); + employs[j] = new Employees(r.nextInt(1,50)); + } + for(int i = 0; i < employs.length; i++) + { + if(employs[i].getYears() >= 20) + System.out.println(employs[i].toString()); + } + + + } +} \ No newline at end of file diff --git a/src/IceCreamMachineStuff/ChocolateIceCreamMachine.java b/src/IceCreamMachineStuff/ChocolateIceCreamMachine.java new file mode 100644 index 0000000..e1905cd --- /dev/null +++ b/src/IceCreamMachineStuff/ChocolateIceCreamMachine.java @@ -0,0 +1,45 @@ +package IceCreamMachineStuff; + +public class ChocolateIceCreamMachine extends IceCreamMachine +{ + private double Cocoa; + private double CocoaConsumption; + public ChocolateIceCreamMachine(double creamconsumption,double sugarconsumption, double cocoaconsumption) + { + this.CocoaConsumption = cocoaconsumption; + this.SugarConsumption = sugarconsumption; + this.CreamConsumption = creamconsumption; + } + + public void addMaterial(double cream,double sugar,double coca) + { + Cream += cream; + Sugar += sugar; + Cocoa += coca; + + } + + public double make(double amount) + { + double made = 0; + while(made < amount && Sugar >= SugarConsumption && Cream >= CreamConsumption && Cocoa >= CocoaConsumption) + { + made++; + Sugar -= SugarConsumption; + Cream -= CreamConsumption; + Cocoa -= CocoaConsumption; + + } + Icecream += made; + return made; + } + + @Override + public String toString() + { + return "No. of Cream: " + Cream + "\nNo. of IceCream: " + Icecream + "\n No. of sugar: " + Sugar + "\nNo. of Cocoa: " + Cocoa; + } + + + +} diff --git a/src/IceCreamMachineStuff/IceCreamMachine.java b/src/IceCreamMachineStuff/IceCreamMachine.java new file mode 100644 index 0000000..005373f --- /dev/null +++ b/src/IceCreamMachineStuff/IceCreamMachine.java @@ -0,0 +1,62 @@ +package IceCreamMachineStuff; + +public class IceCreamMachine +{ + double Cream; + double Sugar; + double Icecream; + double SugarConsumption; + double CreamConsumption; + IceCreamMachine() + { + + } + IceCreamMachine(double creamConsumption,double sugarConsumption) + { + this.CreamConsumption = creamConsumption; + this.SugarConsumption = sugarConsumption; + } + public void addMaterial(double cream,double sugar) + { + Sugar+=sugar; + Cream+=cream; + } + + public double howMuch() + { + double C = Cream; + double S = Sugar; + double amount = 0; + while(C >= CreamConsumption && S >= SugarConsumption) + { + + amount +=1; + C -= CreamConsumption; + S -= SugarConsumption; + } + return amount; + } + public double make(double amount) + { + double made = 0; + while(made < amount && Sugar >= SugarConsumption && Cream >= CreamConsumption) + { + made++; + Sugar -= SugarConsumption; + Cream -= CreamConsumption; + + } + Icecream += made; + return made; + } + public double pack() + { + double packs = Math.rint(Icecream); + return packs; + } + @Override + public String toString() + { + return "No. of Cream: " + Cream + "\nNo. of IceCream: " + Icecream + "\n No. of sugar: " + Sugar; + } +} diff --git a/src/IceCreamMachineStuff/MainProgram.java b/src/IceCreamMachineStuff/MainProgram.java new file mode 100644 index 0000000..7c1fa8a --- /dev/null +++ b/src/IceCreamMachineStuff/MainProgram.java @@ -0,0 +1,15 @@ +package IceCreamMachineStuff; + +public class MainProgram +{ + public static void main(String[] args) + { + ChocolateIceCreamMachine ChoccyGenerator = new ChocolateIceCreamMachine(10,5,3); + ChoccyGenerator.addMaterial(50,25,15); + ChoccyGenerator.make(4); + System.out.println("Amount in machine: " + ChoccyGenerator.pack()); + System.out.println(ChoccyGenerator.toString()); + + } + +} diff --git a/src/Products/Product.class b/src/Products/Product.class new file mode 100644 index 0000000..480b8a4 Binary files /dev/null and b/src/Products/Product.class differ diff --git a/src/Products/Product.java b/src/Products/Product.java new file mode 100644 index 0000000..55835b8 --- /dev/null +++ b/src/Products/Product.java @@ -0,0 +1,48 @@ +package Products; + + +import java.util.Date; + +public class Product +{ + String pname; + double unitprice; + Date expdate = new Date(); + + Product() + { + + } + + Product(String name, double price, Date date) + { + this.pname = name; + this.unitprice = price; + this.expdate = date; + + } + + public boolean checkExpired() + { + Date today = new Date(); + return expdate.before(today); + } + + + + + + + @Override + public String toString() + { + return "Product name: " + pname + "\nUnit price: " + unitprice + "\nExpiration date: " + expdate; + + } + + + + + + +} diff --git a/src/Products/ProductTests.java b/src/Products/ProductTests.java new file mode 100644 index 0000000..1a9ce74 --- /dev/null +++ b/src/Products/ProductTests.java @@ -0,0 +1,30 @@ +package Products; + +import java.util.Date; +public class ProductTests +{ + public static void main(String[] args) + + { + + Date d1 = new Date(2025,10,10); + Date d2 = new Date(2021,10,10); + Date d3 = new Date(2020,10,10); + + + + Product p1 = new Product("A0",100,d1); + Product p2 = new Product("A0",100,d2); + Product p3 = new Product("A0",100,d3); + + + if(p1.checkExpired() == false); + System.out.println("Pog"); + if(p2.checkExpired()==true); + System.out.println("POG"); + + + } + +} + diff --git a/src/Questionaire/QuestionaireChecker.java b/src/Questionaire/QuestionaireChecker.java new file mode 100644 index 0000000..d4ec4c8 --- /dev/null +++ b/src/Questionaire/QuestionaireChecker.java @@ -0,0 +1,55 @@ +package Questionaire; + +import java.util.Scanner; + +public class QuestionaireChecker +{ + public static void main(String[] args) + { + + Scanner input = new Scanner(System.in); + System.out.println("Enter Number of students:"); + int numberOfStudents = input.nextInt(); + + Student[] students = new Student[numberOfStudents]; + + for(int i = 0; i < students.length;i++) + { + System.out.println("enter answers for student " + (i+1)); + students[i] = new Student(); + students[i].answer(); + System.out.println("Answers for student " + (i+1) + " filled"); + } + int[] sameAnswers = checkanswers(students); + + for(int k = 0; k < sameAnswers.length;k++) + { + if(sameAnswers[k] != 0) + System.out.println(sameAnswers[k]); + } + + + } + + public static int[] checkanswers(Student[] students) + { + int[] questions = new int[25]; + for(int i = 0; i < 25; i++) + { + boolean same = true; + int ans1 = students[0].ans[i]; + for(int j = 1; j < students.length; j++) + { + if(ans1 != students[j].ans[i]) + same = false; + } + if(same == true) + questions[i] = i+1; + + } + return questions; + + } + + +} diff --git a/src/Questionaire/Student.java b/src/Questionaire/Student.java new file mode 100644 index 0000000..ca4b593 --- /dev/null +++ b/src/Questionaire/Student.java @@ -0,0 +1,29 @@ +package Questionaire; + +import java.util.Scanner; + +public class Student +{ + + + public int[] ans = new int[25]; + + + public void answer() + { + Scanner input = new Scanner(System.in); + for (int i = 0; i < 25;) + { + int in = input.nextInt(); + if (in >= 1 && in <= 5) + { + ans[i] = in; + i++; + } else + System.out.println("invalid answer"); + + } + + } + +} diff --git a/src/Savings/SavingAccount.java b/src/Savings/SavingAccount.java new file mode 100644 index 0000000..2fe953f --- /dev/null +++ b/src/Savings/SavingAccount.java @@ -0,0 +1,39 @@ +package Savings; +public class SavingAccount +{ + static double interest_rate = 0.10; + + String id; + double amount; + SavingAccount(String Id,double Amount) + { + this.id = Id; + this.amount = Amount; + + } + + public double calc_profit() + { + double profit = amount * interest_rate; + amount+=profit; + return profit; + + } + public static double getInterest() + { + return interest_rate; + + } + + public double getAmount() + { + return amount; + } + + public static void setInterest_rate(double newInt) + { + interest_rate = newInt; + } + + +} diff --git a/src/Savings/SavingForm.java b/src/Savings/SavingForm.java new file mode 100644 index 0000000..300ec59 --- /dev/null +++ b/src/Savings/SavingForm.java @@ -0,0 +1,16 @@ +package Savings; +public class SavingForm +{ + public static void main(String[] args) + { + SavingAccount a1 = new SavingAccount("123asjkljr",500); + + System.out.println("Balance is : "+ a1.getAmount() + " BEFORE profit"); + + double a1profit = a1.calc_profit(); + + System.out.println("Profit is : "+a1profit); + System.out.println("Balance is : "+a1.getAmount()); + + } +} diff --git a/src/Student/Course.java b/src/Student/Course.java new file mode 100644 index 0000000..92f9921 --- /dev/null +++ b/src/Student/Course.java @@ -0,0 +1,41 @@ +package Student; + +public class Course { + private String title; + private int Students; + private final int maxStudents = 10; + Student[] students = new Student[10]; + int count = 0; + + public String Register(Student student) { + if (count < 10) { + students[count] = student; + count++; + return "Success"; + } else { + return "Course full!"; + } + + } + public boolean isFull() + { + if(count ==9) + return true; + else + return false; + } + + public int NumberofStudents() + { + if(students[0].getName().isBlank()) + return 0; + else + return count; + + } + public String title() + { + return title; + } + +} diff --git a/src/Student/Student.java b/src/Student/Student.java new file mode 100644 index 0000000..740745f --- /dev/null +++ b/src/Student/Student.java @@ -0,0 +1,30 @@ +package Student; + +public class Student +{ + private String name; + private String id; + + Student(String n, String Id) + { + this.name=n; + this.id=Id; + } + + public String getName() + { + return name; + } + + public String getId() + { + return id; + } + + public void Register(Course course) + { + //To be done later + } + + +} diff --git a/src/coffee/Batch.java b/src/coffee/Batch.java new file mode 100644 index 0000000..8be51fd --- /dev/null +++ b/src/coffee/Batch.java @@ -0,0 +1,43 @@ +package coffee; + +public class Batch +{ + int amount; + double price; + + + public int addBatch(int Takenout) + { + + if(Takenout >= amount) + return amount; + if(amount == 0) + return 0; + amount-=Takenout; + return Takenout; + } +//ge4ta + + public int getAmount() + { + return amount; + } + + + public int available() + { + return amount; + } + + + + + @Override + public String toString() + { + return "Amount in batch: " + amount + "\nTotal Price: " + price; + } + + + +} diff --git a/src/coffee/Coffee.java b/src/coffee/Coffee.java new file mode 100644 index 0000000..1b42780 --- /dev/null +++ b/src/coffee/Coffee.java @@ -0,0 +1,48 @@ +package coffee; + +import java.util.Date; +import java.util.Stack; + +public class Coffee extends Batch { + String name; + double price; + int stock; + Stack sold_records = new Stack(); + + Coffee() { + + } + + Coffee(String n, double p, int s) { + this.name = n; + this.price = p; + this.stock = s; + } + + public void changePrice(double newprice) { + price = newprice; + } + + public void prepare(int num) { + stock += num; + } + + public void addStock(Batch batch,int amt) + { + prepare(batch.addBatch(amt)); + } + + public void sell(int num) + { + stock-=num; + sold_records.push(new Date()); + } + + + @Override + public String toString() + { + return "Name: " + name + "\nPrice: " + price + "\nStock: "+ stock; + } + +} \ No newline at end of file