Skip to content

Instantly share code, notes, and snippets.

@IamNator
Forked from ogaere/buyandsell.go
Created July 1, 2021 11:38
Show Gist options
  • Save IamNator/96f3ac033af2eb2e0939a9a12dc2fc4b to your computer and use it in GitHub Desktop.
Save IamNator/96f3ac033af2eb2e0939a9a12dc2fc4b to your computer and use it in GitHub Desktop.
Tell me what is wrong with this of code
type Cement struct {
NoOfCement int
}
func (c *Cement) BuyCement(howmany int) {
c.NoOfCement += howmany
}
func (c *Cement) SellCement(howmany int) {
o.NoOfCement -= howmany
}
func (c *Cement) String() string {
return fmt.Sprintf("%v", c.NoOfCement)
}
func main() {
var cement Cement
cement.BuyCement(15)
cement.SellCement(9)
fmt.Println(cement)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment