// Rectangles.swift Copyright (c) Kari Laitinen // http://www.naturalprogramming.com // 2014-10-02 File created. // 2016-11-09 Last modification. import Foundation class Rectangle { var rectangle_width = 0 var rectangle_height = 0 var filling_character = "?" // The underscores in the following function definition specify // that no external names are needed for the two parameters. // It is assumed that the first method parameter does not need // an external name as the method name serves the purpose. func initialize_rectangle( _ given_rectangle_width : Int, _ given_rectangle_height : Int, _ given_filling_character : String ) { rectangle_width = given_rectangle_width rectangle_height = given_rectangle_height filling_character = given_filling_character } func print_rectangle() { for _ in 1 ... rectangle_height { print( "\n ", terminator: "" ) for _ in 1 ... rectangle_width { print( filling_character, terminator: "" ) } } print( "\n" ) } } var first_rectangle = Rectangle() first_rectangle.initialize_rectangle( 7, 4, "Z" ) first_rectangle.print_rectangle() var second_rectangle = Rectangle() second_rectangle.initialize_rectangle( 12, 3, "X" ) second_rectangle.print_rectangle()