Skip to content

Instantly share code, notes, and snippets.

@iamcrypticcoder
Last active March 30, 2018 19:16
Show Gist options
  • Save iamcrypticcoder/358b686b3c93405c4b0f4738caa426bc to your computer and use it in GitHub Desktop.
Save iamcrypticcoder/358b686b3c93405c4b0f4738caa426bc to your computer and use it in GitHub Desktop.
import Foundation
protocol GraphicsAPI {
func drawRectangle(_ x: Int, _ y: Int, _ width: Int, _ height: Int)
func drawCircle(_ x: Int, _ y: Int, _ radius: Int)
}
class DirectXAPI : GraphicsAPI {
func drawRectangle(_ x: Int, _ y: Int, _ width: Int, _ height: Int) {
print("Rectangle drawn by DirectXAPI API");
}
func drawCircle(_ x: Int, _ y: Int, _ radius: Int) {
print("Circle drawn by DirectXAPI API");
}
}
public class OpenGLAPI : GraphicsAPI {
func drawRectangle(_ x: Int, _ y: Int, _ width: Int, _ height: Int) {
print("Rectangle drawn by OpenGL API")
}
func drawCircle(_ x: Int, _ y: Int, _ radius: Int) {
print("Circle drawn by OpenGL API")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment