This file contains hidden or 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
| class TestViewModel @Inject constructor(private val dataRepo: DataRepository) : ViewModel() { | |
| private var dataLiveData = MutableLiveData<Int>() | |
| fun insertUser(user: User) { | |
| dataRepo.insertUser(user) | |
| } | |
| fun deleteUser() { |
This file contains hidden or 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
| class Book { | |
| val name: String = "" | |
| val price: Int = 0; | |
| val author: String = "" | |
| } |
This file contains hidden or 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
| class BookStocks:Book { | |
| val no_of_books: Int = 0; | |
| } |
This file contains hidden or 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
| public interface Car { | |
| void turnOnEngine(); | |
| void accelerate(); | |
| } | |
| public class MotorCar implements Car { | |
| private Engine engine; |
This file contains hidden or 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
| public class ElectricCar implements Car { | |
| public void turnOnEngine() { | |
| throw new AssertionError("I don't have an engine!"); | |
| } | |
| public void accelerate() { | |
| //this acceleration is crazy! | |
| } | |
| } |
This file contains hidden or 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
| public interface Car { | |
| void accelerate(); | |
| } | |
| public interface EngineType { | |
| void turnOnEngine(); | |
| } | |
| /***********************/ |
This file contains hidden or 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
| interface Robot { | |
| fun reset() | |
| fun fly() | |
| fun talk() | |
| } | |
| class ButterflyRobot : Robot { | |
| override fun reset() { | |
| TODO("not implemented") |
This file contains hidden or 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
| interface Robot { | |
| fun reset() | |
| } | |
| interface Flyable { | |
| fun fly() | |
| } | |
| interface Talkable { | |
| fun talk() |
This file contains hidden or 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
| enum OutputDevice {PRINTER, DISK} | |
| public fun copy(OutputDevice dev){ | |
| val c:int | |
| while((c=readKeyBoard)!=EOF){ | |
| if(dev==PRINTER) | |
| { | |
| writePrinter(c) | |
| }else{ | |
| writeToDisk(c) |
This file contains hidden or 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
| interface Reader { | |
| fun read():Char | |
| } | |
| interface Writer { | |
| fun write(ch Char) | |
| } | |
| public fun copy(r Reader, w Writer ){ | |
| var ch Char |