You are on page 1of 2

import java.io.

File

interface LibraryPrinter
{
public fun print(books:Set<Book>)
}

object printHTML:LibraryPrinter
{
override public fun print(books:Set<Book>)
{
val content = File("Librarie.html").writer()
content.write("[\n")
for(book in books)
{
content.write("<html>\n")
content.write("<head>\n")
content.write("<head><title>Libraria mea HTML</title></head>\n")
content.write("</head>\n")
content.write("<body>\n")
content.write("<h1>\n"+book.GetName()+"</h1>\n")
content.write("<h2>\n"+book.GetAuthor()+"</h2>\n")
content.write("<h3>\n"+book.GetContent()+"</h3>\n")
content.write("<h4>\n"+book.GetPublisher()+"</h4>\n")
content.write("<h5>\n"+book.GetPrice()+"</h5>\n")
content.write("</body>\n")
content.write("</html>\n")

}
content.write("]\n")
content.close()
}
}

object printJSON:LibraryPrinter
{

override public fun print(books:Set<Book>)


{
val content = File("Librarie.json").writer()
content.write("[\n")
for(book in books)
{
content.write(" {\"Titlu\": \"${book.GetName()}\", \"Autor\":\"$
{book.GetAuthor()}\", \"Editura\":\"${book.GetPublisher()}\", \"Text\":\"$
{book.GetContent()}\",\"Pret\":\"${book.GetPrice()}\"},\n")
}
content.write("]\n")
content.close()
}

object printRaw:LibraryPrinter
{
override public fun print(books:Set<Book>)
{

for(book in books)
{
println(book.GetAuthor())
println(book.GetContent())
println(book.GetName())
println(book.GetPublisher())
println(book.GetPrice())
}

}
}

You might also like