- Learn Data Structures and Algorithms with Golang
- Bhagvan Kommadi
- 114字
- 2021-06-24 15:37:32
drawContour method
The drawContour method of the DrawContour class calls the drawShape method on the shape instance, this is shown in the following code:
//DrawContour method drawContour given the coordinates
func (contour DrawContour) drawContour(x[5] float32,y[5] float32) {
fmt.Println("Drawing Contour")
contour.shape.drawShape(contour.x,contour.y)
}
//DrawContour method resizeByFactor given factor
func (contour DrawContour) resizeByFactor(factor int) {
contour.factor = factor
}
// main method
func main() {
var x = [5]float32{1,2,3,4,5}
var y = [5]float32{1,2,3,4,5}
var contour IContour = DrawContour{x,y,DrawShape{},2}
contour.drawContour(x,y)
contour.resizeByFactor(2)
}
Run the following commands:
go run bridge.go
The following screenshot displays the output:
![](https://epubservercos.yuewen.com/AA6936/19470380301498306/epubprivate/OEBPS/Images/c0562db0-8f61-409a-b8b9-a50c0d2ca323.png?sign=1739025442-WEafs2r2FrjLggck6pdB9bqOdH29yXjz-0-e92ccf48cb1caed8fe1f9b4af075016b)
We will take a look at Composite, Decorator, Facade and Flyweight design patterns in the next sections.