Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.hackeru.mykotlinapp
- //targil 26/06/2020:
- class ClassTask_2020_06_24 {
- fun main() {
- val nerd = ComputerTeacher("zeev", "mendeli")
- val pewDiePie = Gamer("Felix", "Arvid")
- val myMan = BusinessMan("steve", "jobs")
- nerd.talk()
- nerd.walk()
- nerd.eat()
- pewDiePie.playGame()
- pewDiePie.talk()
- pewDiePie.walk()
- pewDiePie.eat()
- myMan.makeBusiness()
- myMan.talk()
- myMan.walk()
- myMan.eat()
- }
- }
- open class Person(val firstName: String, val lastName: String) {
- fun talk() {
- println("$firstName $lastName saying: \"blah blah blah...\"")
- }
- open fun walk() {
- println("$firstName $lastName is walking")
- }
- fun eat() {
- println("$firstName $lastName is eating")
- }
- }
- class ComputerTeacher : Person {
- var subject: String = "Computers"
- constructor (firstName: String, lastName: String) : super(firstName, lastName) {
- this.subject = subject
- }
- fun teachComputer() {
- println("$subject class is thought by teacher: $firstName $lastName")
- }
- }
- class Gamer : Person {
- var subject: String = "Gamer"
- constructor (firstName: String, lastName: String) : super(firstName, lastName) {}
- fun playGame() {
- println("$firstName $lastName is a $subject playing Call of Duty III: Modern Warfare!")
- }
- }
- class BusinessMan : Person {
- var subject: String = "BusinessMan"
- constructor (firstName: String, lastName: String) : super(firstName, lastName) {}
- fun makeBusiness() {
- println("$firstName $lastName is a $subject making tons of $$$$$$$")
- }
- override fun walk() {
- println("$firstName $lastName dont need to walk, he has BMW!")
- }
- }
Add Comment
Please, Sign In to add comment