kk
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package main
|
||||
|
||||
func add(a,b int) int {
|
||||
return a + b
|
||||
}
|
||||
|
||||
func Sub(a,b int) int {
|
||||
return a - b
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
module Lec20
|
||||
|
||||
go 1.24.4
|
||||
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"Lec20/rectangle"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// res := add(2,5)
|
||||
// fmt.Println("Addition equals to ",res)
|
||||
|
||||
r := rectangle.New(10, 20, "green")
|
||||
fmt.Println("Perimeter: ", r.Perimeter())
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package rectangle
|
||||
|
||||
type Rect struct {
|
||||
A,B int
|
||||
color string
|
||||
}
|
||||
|
||||
func New(newA int, newB int, newColor string) *Rect {
|
||||
return &Rect{newA,newB,newColor}
|
||||
}
|
||||
|
||||
func (r *Rect) Perimeter() int {
|
||||
return 2 * (r.A + r.B)
|
||||
}
|
||||
Reference in New Issue
Block a user