-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #139 from tychy/read-yusenkabu
Read 優先株
- Loading branch information
Showing
4 changed files
with
153 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package toukibo | ||
|
||
import ( | ||
"strconv" | ||
"strings" | ||
) | ||
|
||
type HoujinPreferredStock struct { | ||
Type string `yaml:"Type"` | ||
Amount int `yaml:"Amount"` | ||
} | ||
|
||
type HoujinStock struct { | ||
Total int | ||
Preferred []HoujinPreferredStock | ||
} | ||
|
||
func (s HoujinStock) Sum() int { | ||
sum := 0 | ||
for _, p := range s.Preferred { | ||
sum += p.Amount | ||
} | ||
return sum | ||
} | ||
|
||
func (s HoujinStock) String() string { | ||
var b strings.Builder | ||
for _, p := range s.Preferred { | ||
b.WriteString(" - Type: " + p.Type + "\n") | ||
b.WriteString(" Amount: " + strconv.Itoa(p.Amount) + "\n") | ||
} | ||
return b.String() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters