mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			21 lines
		
	
	
		
			492 B
		
	
	
	
		
			Swift
		
	
	
	
	
	
			
		
		
	
	
			21 lines
		
	
	
		
			492 B
		
	
	
	
		
			Swift
		
	
	
	
	
	
| class Square: NamedShape {
 | |
|     var sideLength: Double
 | |
| 
 | |
|     init(sideLength: Double, name: String) {
 | |
|         self.sideLength = sideLength
 | |
|         super.init(name: name)
 | |
|         numberOfSides = 4
 | |
|     }
 | |
| 
 | |
|     func area() ->  Double {
 | |
|         return sideLength * sideLength
 | |
|     }
 | |
| 
 | |
|     override func simpleDescription() -> String {
 | |
|         return "A square with sides of length \(sideLength)."
 | |
|     }
 | |
| }
 | |
| let test = Square(sideLength: 5.2, name: "my test square")
 | |
| test.area()
 | |
| test.simpleDescription()
 |