summaryrefslogtreecommitdiffstats
path: root/Java/Square/Square.java
diff options
context:
space:
mode:
authormsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
committermsglm <msglm@techchud.xyz>2023-01-14 05:31:48 -0600
commit9d53d8857eaa1c9405894a88ca75bc4657e42f35 (patch)
treeeb1efc1d028b949dd83bb710c68be8eff58f26e7 /Java/Square/Square.java
downloadschool-code-master.tar.gz
school-code-master.tar.bz2
school-code-master.zip
Inital CommitHEADmaster
Diffstat (limited to 'Java/Square/Square.java')
-rw-r--r--Java/Square/Square.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/Java/Square/Square.java b/Java/Square/Square.java
new file mode 100644
index 0000000..4ea72e9
--- /dev/null
+++ b/Java/Square/Square.java
@@ -0,0 +1,43 @@
+public class Square {
+
+ // data member
+ private double length;
+
+
+
+ // Constructors
+ //accepts r as length
+ public Square (double l) {
+ length = l;
+ }
+//no r? assume length is 1
+ public Square() {
+ length = 1;
+ }
+//copy's length from another circle
+ public Square (Square s) {
+ length = s.length;
+ }
+
+ // setter & getter
+ // sets length
+ public void setLength(double l) {
+ length = l;
+ }
+//return length
+ public double getLength() {
+ return length;
+ }
+
+ // other methods
+ public double area() {
+ return Math.pow(length,2);
+ }
+
+ public double perimeter() {
+ return length*4;
+ }
+
+}
+
+