aboutsummaryrefslogtreecommitdiffstats
path: root/csci1913/Java/lab6/Polygon.java
diff options
context:
space:
mode:
authorRossTheRoss <mstrapp@protonmail.com>2019-10-16 14:56:08 -0500
committerRossTheRoss <mstrapp@protonmail.com>2019-10-16 14:56:08 -0500
commit4e15412bd6bbc53bf60dadd1587fff93de2c83b7 (patch)
tree88e79634f953e9cb62c81599bc646e35abe7435f /csci1913/Java/lab6/Polygon.java
parentMove things around (diff)
downloadhomework-4e15412bd6bbc53bf60dadd1587fff93de2c83b7.tar
homework-4e15412bd6bbc53bf60dadd1587fff93de2c83b7.tar.gz
homework-4e15412bd6bbc53bf60dadd1587fff93de2c83b7.tar.bz2
homework-4e15412bd6bbc53bf60dadd1587fff93de2c83b7.tar.lz
homework-4e15412bd6bbc53bf60dadd1587fff93de2c83b7.tar.xz
homework-4e15412bd6bbc53bf60dadd1587fff93de2c83b7.tar.zst
homework-4e15412bd6bbc53bf60dadd1587fff93de2c83b7.zip
Finish lab
Diffstat (limited to '')
-rw-r--r--csci1913/Java/lab6/Polygon.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/csci1913/Java/lab6/Polygon.java b/csci1913/Java/lab6/Polygon.java
new file mode 100644
index 0000000..7f025fe
--- /dev/null
+++ b/csci1913/Java/lab6/Polygon.java
@@ -0,0 +1,32 @@
+package lab6;
+
+class Polygon
+{
+ private int[] sideLengths;
+
+ public Polygon(int sides, int ... lengths)
+ {
+ int index = 0;
+ sideLengths = new int[sides];
+ for (int length: lengths)
+ {
+ sideLengths[index] = length;
+ index += 1;
+ }
+ }
+
+ public int side(int number)
+ {
+ return sideLengths[number];
+ }
+
+ public int perimeter()
+ {
+ int total = 0;
+ for (int index = 0; index < sideLengths.length; index += 1)
+ {
+ total += side(index);
+ }
+ return total;
+ }
+}