当前位置:网站首页>Scala trait exercise
Scala trait exercise
2022-06-25 01:03:00 【Jue Niu thunder plough hot blade】
object practice {
abstract class Coder {
var name: String = _
var age: Int = _
def eat(): Unit
// Skill
def skill(): Unit
}
class JavaCoder extends Coder {
override def eat(): Unit = println("Java Programmers eat cabbage , Rice porridge ")
override def skill(): Unit = println(" Master Java")
}
class PythonCode extends Coder {
override def eat(): Unit = println("Python Programmers eat cabbage , Eat rice porridge ")
override def skill(): Unit = println(" Master Python")
}
trait BigData {
def learningBigData(): Unit = {
println(" After the dark horse ")
println(" Mastered :Hadoop、Zookeeper、HBase、Hive、Spark、Flink etc. ")
println(" Project experience : Enterprise class 360° Full range of user portraits 、 Hundreds of billions of warehouses 、 Dark horse recommendation system 、 Telecommunication signal strength diagnosis ")
}
}
class PartJavaCode extends JavaCoder with BigData {
override def eat(): Unit = {
super.eat()
println(" Master Java + BigData The programmer , Eat beef , And beef soup ")
}
override def skill(): Unit = {
super.skill()
learningBigData()
}
}
class PartPythonCoder extends PythonCode with BigData {
override def eat(): Unit = {
super.eat()
println(" Master Python + BigData The programmer , Eat mutton , Drink mutton soup ")
}
override def skill(): Unit = {
super.skill()
learningBigData()
}
}
def main(args: Array[String]): Unit = {
println(" Ordinary Java The programmer ")
val jc = new JavaCoder
jc.name = " Xyy "
jc.age = 20
println(jc.name, jc.age)
jc.eat()
jc.skill()
println("-" * 20)
println(" Master Java + BigData The programmer ")
val pjc = new PartJavaCode
pjc.name = " Brother dark horse "
pjc.age = 30
println(pjc.name, pjc.age)
pjc.eat()
pjc.skill()
}
}
边栏推荐
- 2021-02-15
- 实现mnist手写数字识别
- Apk decompiled method (not confused)
- 生成订单30分钟未支付,则自动取消,该怎么实现?
- Leetcode 1248. Statistics of "graceful subarray" (harm, suddenly found that it can only enumerate violently)
- QT (36) -rapidjson parsing nested JSON
- 2022熔化焊接与热切割复训题库模拟考试平台操作
- A small program written this week
- adb shell sendevent
- adb shell getevent
猜你喜欢

How to quickly open traffic master for wechat applet

I 刷题 I — 复制带随机指针的链表

Custom animation (simulated win10 loading animation) - Optimization

【Redis实现秒杀业务②】超卖问题的解决方案

Decoupling pages and components using lifecycle

Practical operation notes - notebook plus memory and ash cleaning

Working principle analysis of kubernetes architecture core components

生成订单30分钟未支付,则自动取消,该怎么实现?

Preliminary understanding of qtoolbutton

【微服务|Sentinel】实时监控|RT|吞吐量|并发数|QPS
随机推荐
placeholder
Only positive integers can be entered in the text box
C# 闭包的垃圾回收
Leetcode 1248. Statistics of "graceful subarray" (harm, suddenly found that it can only enumerate violently)
Usage of assert
Activity startup process
2022 simulated 100 questions of safety officer-c certificate examination and online simulated examination
2019 summary and 2020 outlook
How to reduce the font size of custom controls (optimize the round dot progress bar)
Apk slimming compression experience
2022熔化焊接与热切割复训题库模拟考试平台操作
If the order has not been paid for 30 minutes, it will be automatically cancelled. How can I achieve this?
大厂高频软件测试面试题和答案都帮你准备好啦,备战金九银十
Using tcp/udp tools to debug the yeelight ribbon
Single blind box removal, social blind box and friend blind box program source code
Use coordinatorlayout+appbarlayout+collapsingtoolbarlayout to create a collapsed status bar
打卡smart精灵#1,品牌不缺吸引力,产品本身实力如何?
Practical operation notes - notebook plus memory and ash cleaning
腾讯云国际云服务器网络访问丢包问题解决办法
redis + lua实现分布式接口限流实现方案