-
Notifications
You must be signed in to change notification settings - Fork 0
/
RectangularPrism.swift
44 lines (34 loc) · 1.22 KB
/
RectangularPrism.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// RectangularPrism.swift
//
// Created by Brandon Linton and Noah Castle on 4/3/19.
// Copyright © 2019 Brandon Linton and Noah Castle. All rights reserved.
//
import Foundation
class RectangularPrism{
private var length, width, height: Double
init(length: Double, width: Double, height: Double){
self.length = length
self.width = width
self.height = height
}
public func calculateSurfaceArea() -> Double{
var length_times_width, length_times_height, width_times_height: Double
length_times_width = (length * width) //Product of length and width
length_times_height = (length * height) //Product of length and height
width_times_height = (width * height) //Product of width and height
return (2 * ((length_times_width) + (length_times_height) + (width_times_height))) //Calculate surface area
}
public func calculateVolume() -> Double{
return ((length) * (width) * (height)) //Calculate volume
}
public func getLength() -> Double{
return length
}
public func getWidth() -> Double{
return width
}
public func getHeight() -> Double{
return height
}
}