From bbbb324221552fce8d24ac3e14465e1ca9f08192 Mon Sep 17 00:00:00 2001 From: Hammy Date: Sat, 14 Nov 2020 23:58:48 +0000 Subject: [PATCH] Use interface --- Personal/SimpleOOPExample/src/Equation.java | 3 +++ Personal/SimpleOOPExample/src/Line.java | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 Personal/SimpleOOPExample/src/Equation.java diff --git a/Personal/SimpleOOPExample/src/Equation.java b/Personal/SimpleOOPExample/src/Equation.java new file mode 100644 index 0000000..84dbda4 --- /dev/null +++ b/Personal/SimpleOOPExample/src/Equation.java @@ -0,0 +1,3 @@ +public interface Equation { + void displayEquation(); +} diff --git a/Personal/SimpleOOPExample/src/Line.java b/Personal/SimpleOOPExample/src/Line.java index d8c233f..3374712 100644 --- a/Personal/SimpleOOPExample/src/Line.java +++ b/Personal/SimpleOOPExample/src/Line.java @@ -1,4 +1,4 @@ -public class Line { +public class Line implements Equation { private double gradient; private double intercept; @@ -22,6 +22,7 @@ public class Line { intercept = y1 - (gradient * x1); } + @Override public void displayEquation() { System.out.println("y = " + gradient + "x + " + intercept); }