Markou is absolutely insane
This commit is contained in:
14
Semester 4/Assignments/DAO/pom.xml
Normal file
14
Semester 4/Assignments/DAO/pom.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>edu.slcc.asdv.caleb</groupId>
|
||||
<artifactId>DAO</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>20</maven.compiler.source>
|
||||
<maven.compiler.target>20</maven.compiler.target>
|
||||
<exec.mainClass>edu.slcc.asdv.caleb.dao.DAO</exec.mainClass>
|
||||
</properties>
|
||||
</project>
|
20
Semester 4/Assignments/DAO/src/main/java/DAO/DAO.java
Normal file
20
Semester 4/Assignments/DAO/src/main/java/DAO/DAO.java
Normal file
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public interface DAO<T> {
|
||||
public void create(T t);
|
||||
public void delete(T t);
|
||||
public void update(T t);
|
||||
public T find (T t);
|
||||
public Collection<T> findALl();
|
||||
public boolean updateDBase();
|
||||
}
|
19
Semester 4/Assignments/DAO/src/main/java/DAO/Exam.java
Normal file
19
Semester 4/Assignments/DAO/src/main/java/DAO/Exam.java
Normal file
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public interface Exam<T> {
|
||||
void editExam(T t);
|
||||
void takeExam(T t);
|
||||
void submitExam(T t);
|
||||
void previewExam(T t);
|
||||
void monitorExam(T t);
|
||||
void gradeExam(T t);
|
||||
|
||||
}
|
@@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public abstract class ExamFactory<T extends Keyable> {
|
||||
public abstract Exam<T> createExam();
|
||||
}
|
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ExamFactoryOutlet<K, V extends Keyable> extends ExamFactory<Keyable> {
|
||||
|
||||
@Override
|
||||
public Exam<Keyable> createExam()
|
||||
{
|
||||
return new Exam<Keyable>() {
|
||||
@Override
|
||||
public void editExam(Keyable t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void takeExam(Keyable t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void submitExam(Keyable t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void previewExam(Keyable t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void monitorExam(Keyable t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void gradeExam(Keyable t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
15
Semester 4/Assignments/DAO/src/main/java/DAO/Keyable.java
Normal file
15
Semester 4/Assignments/DAO/src/main/java/DAO/Keyable.java
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public interface Keyable<K> {
|
||||
public K getKey();
|
||||
public void setKey(K key);
|
||||
|
||||
}
|
32
Semester 4/Assignments/DAO/src/main/java/DAO/MathExam.java
Normal file
32
Semester 4/Assignments/DAO/src/main/java/DAO/MathExam.java
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class MathExam implements Keyable<MathExam> {
|
||||
ArrayList<Object> fields = new ArrayList<Object>();
|
||||
int key;
|
||||
|
||||
public MathExam(int key, ArrayList<Object> fields) {
|
||||
|
||||
}
|
||||
@Override
|
||||
public MathExam getKey()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKey(MathExam key)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet."); // Generated from nbfs://nbhost/SystemFileSystem/Templates/Classes/Code/GeneratedMethodBody
|
||||
}
|
||||
|
||||
}
|
23
Semester 4/Assignments/DAO/src/main/java/DAO/Test.java
Normal file
23
Semester 4/Assignments/DAO/src/main/java/DAO/Test.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package DAO;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Test {
|
||||
public static void main(String[] args)
|
||||
{
|
||||
ExamFactory<MathExam> efm = new ExamFactory<MathExam>() {
|
||||
@Override
|
||||
public Exam<MathExam> createExam()
|
||||
{
|
||||
System.out.println("Hello World");
|
||||
}
|
||||
};
|
||||
efm.createExam();
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.caleb.dao.factory_pizza;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class CheezePizza implements Pizza {
|
||||
|
||||
@Override
|
||||
public void prepare()
|
||||
{
|
||||
System.out.println("preparing Cheeze Pizza");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bake()
|
||||
{
|
||||
System.out.println("baking Cheeze Pizza");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cut()
|
||||
{
|
||||
System.out.println("cutting Cheeze Pizza");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.caleb.dao.factory_pizza;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class ChickenPizza implements Pizza {
|
||||
|
||||
@Override
|
||||
public void prepare()
|
||||
{
|
||||
System.out.println("preparing Chicken Pizza");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bake()
|
||||
{
|
||||
System.out.println("baking Chicken Pizza");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cut()
|
||||
{
|
||||
System.out.println("cutting Chicken Pizza");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.caleb.dao.factory_pizza;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public interface Pizza<T> {
|
||||
public void prepare(T t);
|
||||
public void bake(T t);
|
||||
public void cut(T t);
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.caleb.dao.factory_pizza;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class PizzaFactory {
|
||||
|
||||
public PizzaFactory(String cheeze)
|
||||
{
|
||||
}
|
||||
public static <T> Pizza<T> createPizza(T type) throws Exception {
|
||||
Pizza p = null;
|
||||
if (type.equals("cheeze"))
|
||||
p = new CheezePizza();
|
||||
else if (type.equals("chicken"))
|
||||
p = new ChickenPizza();
|
||||
else if (type.equals("veggie"))
|
||||
p = new VeggiePizza();
|
||||
if (p == null) {
|
||||
throw new Exception("Not a valid Pizza.");
|
||||
}
|
||||
return p;
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.caleb.dao.factory_pizza;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class PizzaStore {
|
||||
public Pizza orderPizza(String type) throws Exception {
|
||||
Pizza p = PizzaFactory.createPizza(type);
|
||||
p.prepare();
|
||||
p.bake();
|
||||
p.cut();
|
||||
return p;
|
||||
}
|
||||
}
|
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.caleb.dao.factory_pizza;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class TestPizza {
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
PizzaStore ps = new PizzaStore();
|
||||
ps.orderPizza("cheeze");
|
||||
ps.orderPizza("chicken");
|
||||
ps.orderPizza("veggie");
|
||||
}
|
||||
}
|
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package edu.slcc.asdv.caleb.dao.factory_pizza;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class VeggiePizza implements Pizza {
|
||||
|
||||
@Override
|
||||
public void prepare()
|
||||
{
|
||||
System.out.println("Preparing Veggie Pizza");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bake()
|
||||
{
|
||||
System.out.println("Baking Veggie Pizza");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cut()
|
||||
{
|
||||
System.out.println("Cutting Veggie Pizza");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Interface.java to edit this template
|
||||
*/
|
||||
package factory_generic_pizza;
|
||||
|
||||
import edu.slcc.asdv.caleb.dao.factory_pizza.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class Pizza<T> {
|
||||
public void prepare(Object t)
|
||||
{
|
||||
System.out.println("preparing " + t.toString() +" Pizza");
|
||||
}
|
||||
|
||||
public void bake(Object t)
|
||||
{
|
||||
System.out.println("baking " + t.toString() +" Pizza");
|
||||
}
|
||||
|
||||
public void cut(Object t)
|
||||
{
|
||||
System.out.println("cutting" + t.toString() +"Pizza");
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package factory_generic_pizza;
|
||||
|
||||
import edu.slcc.asdv.caleb.dao.factory_pizza.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class PizzaFactory {
|
||||
public static <T> Pizza<T> createPizza(T t)
|
||||
{
|
||||
return new Pizza<T>()
|
||||
{
|
||||
public void prepare(T t) {
|
||||
System.out.println("Preparing pizza " + t.toString() + "...");
|
||||
}
|
||||
|
||||
public void bake(T t) {
|
||||
System.out.println("Baking pizza " + t.toString() + "...");
|
||||
}
|
||||
|
||||
public void cut(T t) {
|
||||
System.out.println("Cutting pizza " + t.toString() + "...");
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package factory_generic_pizza;
|
||||
|
||||
import edu.slcc.asdv.caleb.dao.factory_pizza.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class PizzaStore {
|
||||
public Pizza orderPizza(String type) throws Exception {
|
||||
Pizza p = PizzaFactory.createPizza(type);
|
||||
p.prepare(type);
|
||||
p.bake(type);
|
||||
p.cut(type);
|
||||
return p;
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
package factory_generic_pizza;
|
||||
|
||||
import edu.slcc.asdv.caleb.dao.factory_pizza.*;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author caleb
|
||||
*/
|
||||
public class TestPizza {
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
PizzaStore ps = new PizzaStore();
|
||||
ps.orderPizza("cheeze");
|
||||
ps.orderPizza("chicken");
|
||||
ps.orderPizza("veggie");
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user