Initial commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# Project exclude paths
|
||||||
|
/out/
|
||||||
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -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
|
||||||
6
.idea/misc.xml
generated
Normal file
6
.idea/misc.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/DeansBequest.iml" filepath="$PROJECT_DIR$/DeansBequest.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
11
DeansBequest.iml
Normal file
11
DeansBequest.iml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
26
src/Emploice/Employees.java
Normal file
26
src/Emploice/Employees.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/Emploice/Programs.java
Normal file
24
src/Emploice/Programs.java
Normal file
@@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
45
src/IceCreamMachineStuff/ChocolateIceCreamMachine.java
Normal file
45
src/IceCreamMachineStuff/ChocolateIceCreamMachine.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
62
src/IceCreamMachineStuff/IceCreamMachine.java
Normal file
62
src/IceCreamMachineStuff/IceCreamMachine.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
15
src/IceCreamMachineStuff/MainProgram.java
Normal file
15
src/IceCreamMachineStuff/MainProgram.java
Normal file
@@ -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());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
BIN
src/Products/Product.class
Normal file
BIN
src/Products/Product.class
Normal file
Binary file not shown.
48
src/Products/Product.java
Normal file
48
src/Products/Product.java
Normal file
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
30
src/Products/ProductTests.java
Normal file
30
src/Products/ProductTests.java
Normal file
@@ -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");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
55
src/Questionaire/QuestionaireChecker.java
Normal file
55
src/Questionaire/QuestionaireChecker.java
Normal file
@@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
29
src/Questionaire/Student.java
Normal file
29
src/Questionaire/Student.java
Normal file
@@ -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");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
39
src/Savings/SavingAccount.java
Normal file
39
src/Savings/SavingAccount.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
16
src/Savings/SavingForm.java
Normal file
16
src/Savings/SavingForm.java
Normal file
@@ -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());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
41
src/Student/Course.java
Normal file
41
src/Student/Course.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
30
src/Student/Student.java
Normal file
30
src/Student/Student.java
Normal file
@@ -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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
43
src/coffee/Batch.java
Normal file
43
src/coffee/Batch.java
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
48
src/coffee/Coffee.java
Normal file
48
src/coffee/Coffee.java
Normal file
@@ -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<Date> sold_records = new Stack<Date>();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user