forked from ardanlabs/gotraining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template1.go
25 lines (18 loc) · 876 Bytes
/
template1.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// All material is licensed under the Apache License Version 2.0, January 2004
// http://www.apache.org/licenses/LICENSE-2.0
// Declare a struct that represents a baseball player. Include name, atBats and hits.
// Declare a method that calculates a player's batting average. The formula is Hits / AtBats.
// Declare a slice of this type and initialize the slice with several players. Iterate over
// the slice displaying the players name and batting average.
package main
// Add imports.
// Declare a struct that represents a ball player.
// Include fields called name, atBats and hits.
// Declare a method that calculates the batting average for a player.
func ( /* receiver */ ) average() /* return type */ {
}
func main() {
// Create a slice of players and populate each player
// with field values.
// Display the batting average for each player in the slice.
}