From d77693aebf535085119a9cd86b1aff3f9ebafbbe Mon Sep 17 00:00:00 2001 From: Spencer Smith <smiths@mcmaster.ca> Date: Wed, 14 Mar 2018 00:47:44 -0400 Subject: [PATCH] Remove Java files from spec via uml lecture (using C++ in 2018) --- Lectures/L26_SpecViaUML/src/BankAccount.java | 13 --------- .../src/BankAccountInterface.java | 12 --------- Lectures/L26_SpecViaUML/src/DataSet.java | 27 ------------------- .../src/DataSetBankAccount.java | 26 ------------------ .../L26_SpecViaUML/src/DataSetInterface.java | 26 ------------------ Lectures/L26_SpecViaUML/src/DataSetPoint.java | 25 ----------------- .../L26_SpecViaUML/src/DataSetStrategy.java | 25 ----------------- .../src/DataSetStrategyTest.java | 23 ---------------- Lectures/L26_SpecViaUML/src/DataSetTest.java | 19 ------------- Lectures/L26_SpecViaUML/src/Measurable.java | 4 --- Lectures/L26_SpecViaUML/src/Measurer.java | 4 --- Lectures/L26_SpecViaUML/src/PointT.java | 12 --------- .../L26_SpecViaUML/src/PointTInterface.java | 17 ------------ .../L26_SpecViaUML/src/RectangleMeasurer.java | 10 ------- .../src/TestArraysSortComparable.java | 26 ------------------ 15 files changed, 269 deletions(-) delete mode 100644 Lectures/L26_SpecViaUML/src/BankAccount.java delete mode 100644 Lectures/L26_SpecViaUML/src/BankAccountInterface.java delete mode 100644 Lectures/L26_SpecViaUML/src/DataSet.java delete mode 100644 Lectures/L26_SpecViaUML/src/DataSetBankAccount.java delete mode 100644 Lectures/L26_SpecViaUML/src/DataSetInterface.java delete mode 100644 Lectures/L26_SpecViaUML/src/DataSetPoint.java delete mode 100644 Lectures/L26_SpecViaUML/src/DataSetStrategy.java delete mode 100644 Lectures/L26_SpecViaUML/src/DataSetStrategyTest.java delete mode 100644 Lectures/L26_SpecViaUML/src/DataSetTest.java delete mode 100644 Lectures/L26_SpecViaUML/src/Measurable.java delete mode 100644 Lectures/L26_SpecViaUML/src/Measurer.java delete mode 100644 Lectures/L26_SpecViaUML/src/PointT.java delete mode 100644 Lectures/L26_SpecViaUML/src/PointTInterface.java delete mode 100644 Lectures/L26_SpecViaUML/src/RectangleMeasurer.java delete mode 100644 Lectures/L26_SpecViaUML/src/TestArraysSortComparable.java diff --git a/Lectures/L26_SpecViaUML/src/BankAccount.java b/Lectures/L26_SpecViaUML/src/BankAccount.java deleted file mode 100644 index 9c9b10e6..00000000 --- a/Lectures/L26_SpecViaUML/src/BankAccount.java +++ /dev/null @@ -1,13 +0,0 @@ -public class BankAccount -{ - private double balance; - - public BankAccount() - { balance = 0;} - public void deposit(double amount) - { balance = balance + amount;} - public void withdraw(double amount) - { balance = balance - amount;} - public double getBalance() - { return balance;} -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/BankAccountInterface.java b/Lectures/L26_SpecViaUML/src/BankAccountInterface.java deleted file mode 100644 index 4567091b..00000000 --- a/Lectures/L26_SpecViaUML/src/BankAccountInterface.java +++ /dev/null @@ -1,12 +0,0 @@ -public class BankAccountInterface implements Measurable -{ private double balance; - public BankAccountInterface() - { balance = 0; - } - //.. - public double getBalance() - { return balance; - } - public double getMeasure() - { return balance;} -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/DataSet.java b/Lectures/L26_SpecViaUML/src/DataSet.java deleted file mode 100644 index 2aea56d5..00000000 --- a/Lectures/L26_SpecViaUML/src/DataSet.java +++ /dev/null @@ -1,27 +0,0 @@ -public class DataSet -{ - private double sum; - private double maximum; - private int count; - - public DataSet() - { - sum = 0; - count = 0; - maximum = 0; - } - public void add(double x) - { - sum = sum + x; - if (count == 0 || maximum < x) maximum = x; - count++; - } - public double getAverage() - { - if (count == 0) return 0; - else return sum/count; - } - public double getMaximum() - { return maximum; - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/DataSetBankAccount.java b/Lectures/L26_SpecViaUML/src/DataSetBankAccount.java deleted file mode 100644 index 2b5e7ed3..00000000 --- a/Lectures/L26_SpecViaUML/src/DataSetBankAccount.java +++ /dev/null @@ -1,26 +0,0 @@ -public class DataSetBankAccount -{ - private double sum; - private BankAccount maximum; - private int count; - - public DataSetBankAccount() - { - sum = 0; - count = 0; - maximum = null; - } - public void add(BankAccount x) - { - sum = sum + x.getBalance(); - if (count == 0 || maximum.getBalance() < x.getBalance()) maximum = x; - count++; - } - public double getAverage() - { if (count == 0) return 0; - else return sum/count; - } - public BankAccount getMaximum() - { return maximum; - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/DataSetInterface.java b/Lectures/L26_SpecViaUML/src/DataSetInterface.java deleted file mode 100644 index 7f0a3895..00000000 --- a/Lectures/L26_SpecViaUML/src/DataSetInterface.java +++ /dev/null @@ -1,26 +0,0 @@ -public class DataSetInterface -{ - private double sum; - private Measurable* maximum; - private int count; - - public DataSetInterface() - { - sum = 0; - count = 0; - maximum = null; - } - public void add(Measurable x) - { - sum = sum + x.getMeasure(); - if (count == 0 || maximum.getMeasure() < x.getMeasure()) maximum = x; - count++; - } - public double getAverage() - { if (count == 0) return 0; - else return sum/count; - } - public Measurable getMaximum() - { return maximum; - } -} diff --git a/Lectures/L26_SpecViaUML/src/DataSetPoint.java b/Lectures/L26_SpecViaUML/src/DataSetPoint.java deleted file mode 100644 index fdfb98bd..00000000 --- a/Lectures/L26_SpecViaUML/src/DataSetPoint.java +++ /dev/null @@ -1,25 +0,0 @@ -public class DataSetPoint -{ - private double sum; - private PointT maximum; - private int count; - public DataSetPoint() - { sum = 0; - count = 0; - maximum = null; - } - public void add(PointT x) - { - sum = sum + x.distToOrigin(); - if (count == 0 || maximum.distToOrigin() < x.distToOrigin()) maximum = x; - count++; - } - public double getAverage() - { if (count == 0) return 0; - else return sum/count; - } - public PointT getMaximum() - { - return maximum; - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/DataSetStrategy.java b/Lectures/L26_SpecViaUML/src/DataSetStrategy.java deleted file mode 100644 index bbddd819..00000000 --- a/Lectures/L26_SpecViaUML/src/DataSetStrategy.java +++ /dev/null @@ -1,25 +0,0 @@ -public class DataSetStrategy -{ private double sum; - private Object maximum; - private int count; - private Measurer measurer; - public DataSetStrategy(Measurer aMeasurer) - { sum = 0; - count = 0; - maximum = null; - measurer = aMeasurer; - } - public void add(Object x) - { - sum = sum + measurer.measure(x); - if (count == 0 || measurer.measure(maximum) < measurer.measure(x)) maximum = x; - count++; - } - public double getAverage() - { if (count == 0) return 0; - else return sum/count; - } - public Object getMaximum() - { return maximum; - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/DataSetStrategyTest.java b/Lectures/L26_SpecViaUML/src/DataSetStrategyTest.java deleted file mode 100644 index 2febfa5d..00000000 --- a/Lectures/L26_SpecViaUML/src/DataSetStrategyTest.java +++ /dev/null @@ -1,23 +0,0 @@ -import java.awt.Rectangle; -public class DataSetStrategyTest -{ - public static void main(String[] args) - { - class RectangleMeasurer implements Measurer - { - public double measure(Object anObject) - { - Rectangle aRectangle = (Rectangle) anObject; - double area = aRectangle.getWidth() * aRectangle.getHeight(); - return area; - } - } - Measurer m = new RectangleMeasurer(); - DataSetStrategy data = new DataSetStrategy(m); - data.add(new Rectangle(5, 10, 20, 30)); - data.add(new Rectangle(10, 20, 30, 40)); - System.out.println("Average area = " + data.getAverage()); - Rectangle max = (Rectangle) data.getMaximum(); - System.out.println("Maximum area = " + m.measure(max)); - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/DataSetTest.java b/Lectures/L26_SpecViaUML/src/DataSetTest.java deleted file mode 100644 index 2963e8dd..00000000 --- a/Lectures/L26_SpecViaUML/src/DataSetTest.java +++ /dev/null @@ -1,19 +0,0 @@ -public class DataSetTest -{ public static void main(String[] args) - { DataSetInterface bankData = new DataSetInterface(); - bankData.add(new BankAccountInterface()); - BankAccountInterface b = new BankAccountInterface(); - b.deposit(134.56); - bankData.add(b); - System.out.println("Average balance = " + bankData.getAverage()); - Measurable max = bankData.getMaximum(); - System.out.println("Highest balance = " + max.getMeasure()); - DataSetInterface pointData = new DataSetInterface(); - pointData.add(new PointTInterface(1.0, 1.0)); - pointData.add(new PointTInterface(2.0, 2.0)); - pointData.add(new PointTInterface(3.0, 3.0)); - System.out.println("Average distance to origin = " + pointData.getAverage()); - max = pointData.getMaximum(); - System.out.println("Greatest distance to origin = " + max.getMeasure()); - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/Measurable.java b/Lectures/L26_SpecViaUML/src/Measurable.java deleted file mode 100644 index fb4b5d41..00000000 --- a/Lectures/L26_SpecViaUML/src/Measurable.java +++ /dev/null @@ -1,4 +0,0 @@ -public interface Measurable -{ - double getMeasure(); -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/Measurer.java b/Lectures/L26_SpecViaUML/src/Measurer.java deleted file mode 100644 index 720a9e14..00000000 --- a/Lectures/L26_SpecViaUML/src/Measurer.java +++ /dev/null @@ -1,4 +0,0 @@ -public interface Measurer -{ - double measure(Object anObject); -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/PointT.java b/Lectures/L26_SpecViaUML/src/PointT.java deleted file mode 100644 index d1261c56..00000000 --- a/Lectures/L26_SpecViaUML/src/PointT.java +++ /dev/null @@ -1,12 +0,0 @@ -import static java.lang.Math.*; -public class PointT { - private double xc; - private double yc; - public PointT(double x, double y) { - xc = x; - yc = y;} - // .. - public double distToOrigin() { - return sqrt(pow(xc,2.0) + pow(yc,2.0)); - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/PointTInterface.java b/Lectures/L26_SpecViaUML/src/PointTInterface.java deleted file mode 100644 index af637f83..00000000 --- a/Lectures/L26_SpecViaUML/src/PointTInterface.java +++ /dev/null @@ -1,17 +0,0 @@ -import static java.lang.Math.*; -public class PointTInterface implements Measurable -{ - private double xc; - private double yc; - public PointTInterface(double x, double y) { - xc = x; - yc = y; - } - //.. - public double distToOrigin() { - return sqrt(pow(xc,2.0) + pow(yc,2.0)); - } - public double getMeasure(){ - return distToOrigin(); - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/RectangleMeasurer.java b/Lectures/L26_SpecViaUML/src/RectangleMeasurer.java deleted file mode 100644 index c6e4e5b2..00000000 --- a/Lectures/L26_SpecViaUML/src/RectangleMeasurer.java +++ /dev/null @@ -1,10 +0,0 @@ -import java.awt.Rectangle; -class RectangleMeasurer implements Measurer -{ - public double measure(Object anObject) - { - Rectangle aRectangle = (Rectangle) anObject; - double area = aRectangle.getWidth() * aRectangle.getHeight(); - return area; - } -} \ No newline at end of file diff --git a/Lectures/L26_SpecViaUML/src/TestArraysSortComparable.java b/Lectures/L26_SpecViaUML/src/TestArraysSortComparable.java deleted file mode 100644 index 9b3bce3f..00000000 --- a/Lectures/L26_SpecViaUML/src/TestArraysSortComparable.java +++ /dev/null @@ -1,26 +0,0 @@ -import java.util.Arrays; -public class TestArraysSortComparable -{ public static void main(String [] args) - { PointT[] p = new PointT[6]; - p[0] = new PointT(0.0, 0.0); - p[1] = new PointT(10.0, 30.0); - p[2] = new PointT(4.0, 15.0); - p[3] = new PointT(41.0, 7.0); - p[4] = new PointT(9.0, 70.0); - System.out.println("p[0] compared to p[1]: " + p[0].compareTo(p[1])); - PrintPath(p, 6); - Arrays.sort(p); - PrintPath(p, 6); - } - private static void PrintPath(PointT[] pl, int n) - { int i; - PointT p; - System.out.println(); - System.out.println("i" + "\t" + "xcoord" + "\t" + "ycoord"); - for (i = 0; i < n; i++) - { p = pl[i]; - System.out.println(i + "\t" + p.xcoord() + "\t" + p.ycoord()); - } - System.out.println(); - } -} \ No newline at end of file -- GitLab