Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File
- import java.io.FileWriter
- import java.io.InvalidObjectException
- import javax.management.ImmutableDescriptor
- import kotlin.random.Random
- open class Arma(var nome: String = "none", protected var dannoBase: Int = 1) {
- init { require(dannoBase>=0) }
- fun spara() {
- println("Danno cinetico: $dannoBase")
- }
- }
- class ArmaElettrica(nome: String = "none", dannoBase: Int = 1, var livelloDannoElementale: Int = 1)
- : Arma(nome, dannoBase) {
- init {
- require(livelloDannoElementale in 1..5)
- }
- fun metodoClasseFiglia() {
- println(dannoBase)
- }
- }
- fun main() {
- val unArmaElettrica = ArmaElettrica("Folgorator", 80, 3)
- println("${unArmaElettrica.nome} ${unArmaElettrica.metodoClasseFiglia()}" )
- unArmaElettrica.spara()
- }
Advertisement
Add Comment
Please, Sign In to add comment