Files
learngo/x-tba/project-pricings/print.go

38 lines
755 B
Go
Raw Normal View History

2019-04-11 23:50:22 +03:00
// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
2019-04-23 00:30:53 +03:00
package main
2019-04-11 23:50:22 +03:00
import (
"fmt"
"strings"
)
2019-04-23 00:30:53 +03:00
// show shows the given properties
func show(props []property) {
showHeader()
2019-04-11 23:50:22 +03:00
2019-04-23 00:30:53 +03:00
for _, p := range props {
fmt.Printf("%-15s", p.location)
fmt.Printf("%-15d", p.size)
fmt.Printf("%-15d", p.beds)
fmt.Printf("%-15d", p.baths)
fmt.Printf("%-15d", p.price)
2019-04-11 23:50:22 +03:00
fmt.Println()
}
}
2019-04-23 00:30:53 +03:00
// showHeader prints the header
func showHeader() {
2019-04-11 23:50:22 +03:00
const header = "Location,Size,Beds,Baths,Price"
for _, h := range strings.Split(header, separator) {
fmt.Printf("%-15s", h)
}
fmt.Printf("\n%s\n", strings.Repeat("=", 75))
}