Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions diary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<title>Diary</title>
</head>

<body>
<script src="./diary.js"></script>
</body>

</html>
54 changes: 54 additions & 0 deletions diary.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
class Daily {
constructor(name) {
this.name = name
}
wake() {
console.log(`早上,${this.name}起床了`)
}
walk() {
console.log(`${this.name}走路`)
}
work() {
console.log(`${this.name}工作`)
}

eat(type) {
console.log(`${this.name}吃${type}饭`)
}

exercise() {
console.log(`${this.name}在运动`)
}

sleep() {
console.log(`晚上,${this.name}睡觉`)
}
}

class HeadLine {
constructor(date, location, weather) {
this.date = date
this.location = location
this.weather = weather
}
headDaily() {
console.log(`${this.date} ${this.location} ${this.weather}:`)
}
}

const DATE = '2019年6月22日'
const LOCATION = '北京'
const WEATER = '晴'

const headToday = new HeadLine(DATE, LOCATION, WEATER)
const me = new Daily('我')

headToday.headDaily()
me.wake()
me.eat('早')
me.walk()
me.work()
me.eat('午')
me.exercise()
me.eat('晚')
me.sleep()