2017-02-23-面向对象
Xplorist Lv6

2017-02-23-面向对象

实例1:

创建方法,让人能够同时和猫狗玩,让人能够跟很多个猫玩,人能够和很多个狗玩

思路:方法重载

核心代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
public void play(Cat cat, int n) {
        System.out.println(name+"和"+n+"只猫玩");
        for(int i=0;i<n;i++){
            switch (i) {
            case 0:
                cat.name="小灰";
                break;
                
            case 1:
                cat.name="小白";
                break;
            case 2:
                cat.name="小黑";
                break;
            case 3:
                cat.name="小红";
                break;
            case 4:
                cat.name="小黄";
                break;
            case 5:
                cat.name="小蓝";
                break;

            default:
                cat.name="流浪猫";
                break;
            }
            System.out.println(name+"和"+cat.name+"玩");
        }
    }
    
    public void play( int n) {
        System.out.println(name+"和"+n+"只猫玩");
        for(int i=0;i<n;i++){
            Cat cat=new Cat();
            switch (i) {
            case 0:
                cat.name="小灰";
                break;
                
            case 1:
                cat.name="小白";
                break;
            case 2:
                cat.name="小黑";
                break;
            case 3:
                cat.name="小红";
                break;
            case 4:
                cat.name="小黄";
                break;
            case 5:
                cat.name="小蓝";
                break;

            default:
                cat.name="流浪猫";
                break;
            }
            System.out.println(name+"和"+cat.name+"玩");
        }

实例2:

用户要拿什么茶叶,我们通过对象就给用户什么茶叶,杯子也一样

思路:构造方法

核心代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
public class Cup {
    
    public String name;
    
    public Cup(){
        
    }
    public Cup(String n){
        name=n;
    }
    
    public void makeTea(Tea t){
        System.out.print(name+"泡了一杯"+t.taste+"味道的"+t.name);
    }
}

public class Tea {
    public String name;
    public String taste;
    
    public Tea(){
        
    }
    public Tea(String n,String t){
        name=n;
        taste=t;
    }
}

public class Human {
    public String name;
    
    public Human(){
        
    }
    public Human(String n){
        name=n;
    }
    
    public void drink(Cup c,Tea t){
        System.out.print(name+"拿起了");
        c.makeTea(t);
        System.out.println("然后喝了");
    }
    
}

public class MainGate {

    public static void main(String[] args) {
        Human h=new Human("【张三】");
        Cup c=new Cup("【玻璃杯】");
        Tea t=new Tea("【茉莉花茶】","【清香扑鼻的】");
        h.drink(c, t);
    }

}

实例3:

开枪 需求: 
 * 1、用户可以选择枪4.ak47 mp4 ,火箭筒,如果用户乱来就给他一把玩具枪
 * 2、选完枪以后,用户可以上子弹,但是上子弹之前用户可以选择上什么子弹 10mm(AK47),11,火箭弹,只有子弹选择正确才能上弹成功
 * 3、如果上弹失败,用户可以继续选择上子弹或者退出 
 * 4、上弹成功以后,如果是全自动的枪则直接打完所有子弹,
 * 5、如果是半自动,上完子弹后,我们输入任意一个字符就可以打出一发子弹 
 * 6、子弹打完以后,询问是否上子弹,还是退出, 选择上子弹则可以继续3-6的过程。

分析:主要是控制流程

核心代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
public class GunFire {
    public static void main(String[] args) {
        System.out.println("请输入您要使用的枪:1.AK47;2.MP4;3.RPG火箭筒;");
        Scanner scanner=new Scanner(System.in);
        int inputGun=scanner.nextInt();
        Gun gun=new Gun(inputGun);
        
        gun.reload();
        
        
    }
}

public class Gun {
    public String name;
    public Ammo ammo;
    public boolean auto;

    public Gun(int n) {
        ammo = new Ammo();
        switch (n) {
        case 1:
            name = "AK47";
            ammo.name = "10mm(AK47)";
            auto = false;
            break;
        case 2:
            name = "MP4";
            ammo.name = "11mm(MP4)";
            auto = true;
            break;
        case 3:
            name = "RPG火箭筒";
            ammo.name = "火箭弹(RPG)";
            auto = false;
            break;

        default:
            name = "3岁小孩的玩具枪";
            ammo.name = "气球都打不爆的橡胶子弹";
            auto = false;
            break;
        }
    }

    public void reload() {
        Ammo a = null;
        boolean flag = true;
        boolean flag1 = true;
        boolean flag2 = true;
        boolean flag3 = true;
        Scanner sc = new Scanner(System.in);

        while (flag) {
            System.out.println("开始上弹···");
            flag1 = true;
            while (flag1) {
                //

                System.out.println("恭喜您选择了【" + name + "】,小提示:这种武器一般只使用【" + ammo.name + "】这种弹药哦");
                System.out.println("请输入您要使用的弹药:1.10mm(AK47);2.11mm(MP4);3.火箭弹(RPG);");
                int inputAmmo = sc.nextInt();
                a = new Ammo(inputAmmo);

                flag3 = true;
                while (flag3) {
                    if (ammo.name.equals(a.name)) {
                        System.out.println("上弹成功!");
                        if (auto) {
                            for (int i = 0; i < a.number; i++) {
                                System.out.println("第" + (i + 1) + "发子弹");
                                if (i == (a.number - 1)) {
                                    System.out.println("子弹已经打完了");
                                    System.out.println("请问是否继续上弹,放弃上弹请输入quit,确认上弹请任意输入");
                                    String str = sc.next();
                                    if (str.equals("quit")) {
                                        flag = false;
                                        flag3 = false;
                                    }
                                }

                            }
                            System.out.println("在你试着扣动扳机后,一瞬间打完了所有的弹药。……你被惊呆了!!!");
                        } else {

                            for (int i = 0; i < a.number; i++) {
                                System.out.println("你拿到的是一把半自动的武器【" + name + "】,请输入一个1,发出子弹。");
                                flag2 = true;
                                while (flag2) {
                                    int input = sc.nextInt();
                                    if (input == 1) {
                                        System.out.println(
                                                "biu,这把" + name + "发出了弹匣里" + a.number + "发子弹的第【" + (i + 1) + "】发子弹。");
                                        if (i == (a.number - 1)) {
                                            System.out.println("您已经打完了最后一发子弹");
                                            System.out.println("请问是否继续上弹,放弃上弹请输入quit,确认上弹请任意输入");
                                            String stri = sc.next();
                                            if (stri.equals("quit")) {
                                                System.out.println("您已经退出上弹。");
                                                System.out.println("您已经退出本次使用,欢迎再次光临。");
                                                flag = false;
                                                flag3 = false;
                                            }

                                        }
                                        flag2 = false;

                                    } else {
                                        System.out.println("你并没有扣动扳机,所以什么都没有发生……请继续扣动扳机,按个1没那么难吧。");
                                    }
                                }
                            }
                            flag1 = false;
                        }
                    } else {
                        System.out
                                .println("上弹失败" + name + "并不适合" + a.name + "这种弹药,请问您是否还想继续上弹,退出请输入quit,继续上弹请输入其它任意命令:");
                        String str = sc.next();
                        if (str.equals("quit")) {
                            System.out.println("您已经退出上弹。");
                            System.out.println("您已经退出本次使用,欢迎再次光临。");
                            flag1 = false;
                            flag = false;
                        }
                    }
                }
            }

        }
    }

}

public class Ammo {
    public String name;
    public int number;
    
    public Ammo(){
        
    }
    
    public Ammo(int n){
        switch (n) {
        case 1:
            name="10mm(AK47)";
            number=3;
            break;
        case 2:
            name="11mm(MP4)";
            number=4;
            break;
        case 3:
            name="火箭弹(RPG)";
            number=1;
            break;

        default:
            name="气球都打不爆的橡胶子弹";
            number=1;
            break;
        }
    }
    
}

上面的思路是将所有的流程封装在一个方法里面,在main方法里面调用的时候很方便,缺点是流程太过于复杂。

更好的思路是将流程控制放在一个单独的流程控制类,然后在流程控制类中的主方法里面写具体的流程,但是这样的重用性较差。

新思路核心代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
public class Start {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请选择你的枪:1.手枪,2.AK47,3.Mp4,4.火箭筒");
        // 用户选择的枪
        String inputGun = sc.next();
        // 自己去拿一把枪给用户
        Gun gun = new Gun(inputGun);
        System.out.println("你是否需要上消声器y/n");
        String is = sc.next();
        int i = 0;
        if (is.equalsIgnoreCase("y")) {
            boolean isMuffler=false;
            while (!isMuffler) {
                i++;
                System.out.println("请选择你的消声器:1.1,2.2,3.3,4.4");
                String inputMuffler = sc.next();
                Muffler muffler = new Muffler(inputMuffler);
                // 给枪上消声器
                isMuffler = gun.updateMuffler(muffler);
                if (i == 3) {
                    break;
                }
            }
        }
        while (true) {
            boolean isflag = true;
            boolean flag = false;
            while (!flag) {
                System.out.println("请选择你要上的子弹:1.手枪子弹,2AK47子弹,3MP4子弹,4.火箭弹");
                // 用户选择的子弹
                String inputBullet = sc.next();
                // 给用户拿子弹
                Bullet bullet = new Bullet(inputBullet);
                // 上子弹
                flag = gun.update(bullet);
                // System.out.println(flag);
                // 判断是否继续上子弹
                if (!flag) {
                    System.out.println("继续上子弹输入任意字符,输入quit退出");
                    String isUpBullet = sc.next();
                    // 判断是否在上弹阶段退出游戏;
                    if (isUpBullet.equals("quit")) {
                        isflag = false;
                        break;
                    }
                }
            }
            // 根据用户意愿退出游戏
            if (!isflag) {
                break;
            }
            // 根据子弹数量进行开火
            while (gun.i > 0) {
                // 全自动开火
                if (gun.type.equals("全自动")) {
                    gun.fire();
                } else {
                    // 半自动开火
                    System.out.println("请输入一个任意字符开枪");
                    sc.next();
                    gun.fire();
                }
            }
            // 开火完毕,询问是否退出
            System.out.println("输入reading继续上子弹,输入quit退出");
            String isQuit = sc.next();
            if (isQuit.equals("quit")) {
                break;
            }
        }
    }

}

高亮显示的部分为死循环控制的精辟所在。

实例4:

我们提供1块石头,
,然后人可以将石头磨成对应的石刀,
不同的石头摸出来的刀是不一样的,
人可以拿着刀去看树,不同的树会变成不同的木材,
人可以将木材加工成不同的椅子。

思路分析:关键在于面向对象和流程控制

核心代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
public class Start {
    
    
    public static void main(String[] args) {
        System.out.println("请选择一种石头,【1】石英石,【2】大理石,【3】石灰石,【乱输】泥土:");
        Scanner sc=new Scanner(System.in);
        String inputStone=sc.next();
        
        Stone stone=new Stone(inputStone);
        Human human=new Human();
        
        //人打磨石头得到石刀
        StoneKnife stoneKnife=human.grind(stone);
        System.out.println(human.name+"通过打磨"+stone.solidity+"的"+stone.name+"得到了"+stoneKnife.tartness+"的"+stoneKnife.name);
        
        //
        System.out.println("请选择您要砍的树,【1】松树,【2】桦树,【3】椿树,【乱输】枯树:");
        String inputTree=sc.next();
        
        Tree tree=new Tree(inputTree);
        
        //人砍树得到木材
        Timber timber=human.cutTree(tree, stoneKnife);
        System.out.println(human.name+"用"+stoneKnife.name+"砍了一些"+tree.name+"得到了一些"+timber.name);
        
        //人用得到的木材做椅子
        Chair chair=human.makeChair(timber);
        System.out.println(human.name+"用"+timber.name+"做了一些"+chair.sturdy+"的"+chair.name);
        
        
    }

}

public class Stone {
    /** 石头的名字 */
    public String name;
    /** 石头的坚固程度 */
    public String solidity;
    

    public Stone(String n) {
        switch (n) {
        case "1":
            name = "石英石";
            solidity = "最硬";
            break;
        case "2":
            name = "大理石";
            solidity = "坚固";
            break;
        case "3":
            name = "石灰石";
            solidity = "松软";
            break;

        default:
            name = "泥土";
            solidity = "松散";
            break;
        }
    }
}

public class StoneKnife {
    /** 石刀的名字 */
    public String name;
    /** 石刀的锋利程度 */
    public String tartness;
    /** 石刀的材料 */
    public Stone material;

    public StoneKnife(){
        
    }

}

public class Tree {
    public String name;
    public String sturdy;
    
    public Tree(String n){
        switch (n) {
        case "1":
            name="松树";
            sturdy="坚固";
            break;
        case "2":
            name="桦树";
            sturdy="结实";
            break;
        case "3":
            name="椿树";
            sturdy="松动";
            break;

        default:
            name="枯树";
            sturdy="一碰就碎";
            break;
        }
    }
}

public class Timber {
    public String name;
    public String sturdy;
    public Tree material;
    
    public Timber(){
        
    }
}

public class Chair {
    public String name;
    public String sturdy;
    public Timber material;
    
    public Chair(){
        
    }
    }



public class Human {
    /**人的名字*/
    public String name;
    
    public Human(){
        name="张三";
    }
    
    /**打磨石头得到石刀*/
    public StoneKnife grind(Stone stone){
        StoneKnife sk=null;
        switch (stone.name) {
        case "石英石":
            sk=new StoneKnife();
            sk.name=stone.name+"刀";
            sk.tartness="锐利";
            sk.material=stone;
            break;
        case "大理石":
            sk=new StoneKnife();
            sk.name=stone.name+"刀";
            sk.tartness="锋利";
            sk.material=stone;
            break;
        case "石灰石":
            sk=new StoneKnife();
            sk.name=stone.name+"刀";
            sk.tartness="很钝";
            sk.material=stone;
            break;

        default:
            sk=new StoneKnife();
            sk.name=stone.name+"刀";
            sk.tartness="什么都砍不动";
            sk.material=stone;
            break;
        }
        return sk;
    }
    
    /**拿刀砍树*/
    public Timber cutTree(Tree tree,StoneKnife stoneKnife){
        Timber timber=null;
        switch (tree.name) {
        case "松树":
            timber=new Timber();
            timber.name=tree.name+"木材";
            timber.sturdy=tree.sturdy;
            timber.material=tree;
            break;
        case "桦树":
            timber=new Timber();
            timber.name=tree.name+"木材";
            timber.sturdy=tree.sturdy;
            timber.material=tree;
            break;
        case "椿树":
            timber=new Timber();
            timber.name=tree.name+"木材";
            timber.sturdy=tree.sturdy;
            timber.material=tree;
            break;

        default:
            timber=new Timber();
            timber.name=tree.name+"木材";
            timber.sturdy=tree.sturdy;
            timber.material=tree;
            break;
        }
        
        
        return timber;
    }
    
    /**用木材做椅子*/
    public Chair makeChair(Timber timber){
        Chair chair=null;
        
        switch (timber.name) {
        case "松树木材":
            chair=new Chair();
            chair.name="椅子";
            chair.sturdy=timber.sturdy;
            chair.material=timber;
            break;
        case "桦树木材":
            chair=new Chair();
            chair.name="椅子";
            chair.sturdy=timber.sturdy;
            chair.material=timber;
            break;
        case "椿树木材":
            chair=new Chair();
            chair.name="椅子";
            chair.sturdy=timber.sturdy;
            chair.material=timber;
            break;

        default:
            chair=new Chair();
            chair.name=timber.name+"椅子";
            chair.sturdy=timber.sturdy;
            chair.material=timber;
            break;
        }
        
        return chair;
    }
    
}
 评论
// variables $gt-color-main := #6190e8 $gt-color-sub := #a1a1a1 $gt-color-loader := #999999 $gt-color-error := #ff3860 $gt-color-hr := #e9e9e9 $gt-color-comment-txt := #333333 $gt-color-link-active := #333333 $gt-color-btn := #ffffff $gt-size-base := 16px // default font-size $gt-size-border-radius := 5px $gt-breakpoint-mobile := 479px $gt-mask-z-index := 9999 // functions & mixins clearfix() { &:before &:after { display table clear both content "" } } em($px, $base-size = $gt-size-base) { u = unit($px) if (u is 'px') { unit($px / $base-size, 'em') } else { unit($px, u) } } mobile() { @media (max-width $gt-breakpoint-mobile) { {block} } } // variables - calculated $gt-size-loader-dot := em(6px) $gt-size-loader := em(28px) $gt-size-avatar := em(50px) $gt-size-avatar-mobi := em(32px) // styles // Put everything under container to avoid style conflicts .comments-container { .gt-container { box-sizing border-box * { box-sizing border-box } font-size $gt-size-base // common a { color $gt-color-main &:hover { color lighten($gt-color-main, 20%) border-color lighten($gt-color-main, 20%) } &.is--active { color $gt-color-link-active cursor default !important &:hover { color $gt-color-link-active } } } .hide { display none !important } // icons .gt-svg { display inline-block width em(16px) height em(16px) vertical-align sub svg { width 100% height 100% fill $gt-color-main } } .gt-ico { display inline-block &-text { margin-left em(5px) } &-github { width 100% height 100% .gt-svg { width 100% height 100% } svg { fill inherit } } } // loader .gt-spinner { position relative &::before { position absolute top 3px box-sizing border-box width em(12px) height em(12px) margin-top em(-3px) margin-left em(-6px) border 1px solid $gt-color-btn border-top-color $gt-color-main border-radius 50% animation gt-kf-rotate 0.6s linear infinite content '' } } .gt-loader { position relative display inline-block width $gt-size-loader height $gt-size-loader font-style normal // font-size: $gt-size-loader line-height $gt-size-loader border 1px solid $gt-color-loader border-radius 50% animation ease gt-kf-rotate 1.5s infinite &:before { position absolute top 0 left 50% display block width $gt-size-loader-dot height $gt-size-loader-dot margin-top -($gt-size-loader-dot / 2) margin-left -($gt-size-loader-dot / 2) background-color $gt-color-loader border-radius 50% content '' } } // avatar .gt-avatar { display inline-block width $gt-size-avatar height $gt-size-avatar +mobile() { width $gt-size-avatar-mobi height $gt-size-avatar-mobi } img { width 100% height auto border-radius 3px } &-github { width $gt-size-avatar - em(2px) height $gt-size-avatar - em(2px) cursor pointer +mobile() { width $gt-size-avatar-mobi - em(2px) height $gt-size-avatar-mobi - em(2px) } } } // button .gt-btn { display inline-block padding em(12px) em(20px) color $gt-color-btn font-size em(12px) line-height 1 white-space nowrap text-decoration none background-color $gt-color-main border 1px solid $gt-color-main border-radius $gt-size-border-radius outline none cursor pointer &-text { font-weight 400 } &-loading { position relative display inline-block width em(12px) height em(16px) margin-left em(8px) vertical-align top } &.is--disable { cursor not-allowed opacity 0.5 } &-login { margin-right 0 } &-preview { color $gt-color-main background-color var(--background-color) &:hover { background-color var(--second-background-color) } } &-public { &:hover { background-color lighten($gt-color-main, 20%) border-color lighten($gt-color-main, 20%) } } } } &-loadmore // loadmore /* error */ .gt-error { margin em(10px) color $gt-color-error text-align center } // initing .gt-initing { padding em(20px) 0 text-align center &-text { margin em(10px) auto font-size 92% } } // no int .gt-no-init { padding em(20px) 0 text-align center } // link .gt-link { border-bottom 1px dotted $gt-color-main &-counts &-project { text-decoration none } } // meta .gt-meta { position relative z-index 10 margin em(20px) 0 padding em(16px) 0 font-size em(16px) border-bottom 1px solid $gt-color-hr clearfix() } .gt-counts { margin 0 em(10px) 0 0 color var(--default-text-color) } .gt-user { float right margin 0 font-size 92% &-pic { width 16px height 16px margin-right em(8px) vertical-align top } &-inner { display inline-block cursor pointer .gt-user-name { color var(--default-text-color) } } .gt-ico { margin 0 0 0 em(5px) svg { fill var(--default-text-color) } } .is--poping { .gt-ico { svg { fill $gt-color-main } } } } .gt-version { margin-left em(6px) color $gt-color-sub } .gt-copyright { margin 0 em(15px) em(8px) padding-top em(8px) border-top 1px solid var(--border-color) } // popup .gt-popup { position absolute top em(38px) right 0 display inline-block padding em(10px) 0 font-size em(14px) letter-spacing 0.5px background var(--background-color) border 1px solid var(--border-color) .gt-action { position relative display block margin em(8px) 0 padding 0 em(18px) text-decoration none cursor pointer &.is--active { &:before { position absolute top em(7px) left em(8px) width em(4px) height em(4px) background $gt-color-main content '' } } } } // header .gt-header { position relative display flex &-comment { flex 1 margin-left em(20px) +mobile() { margin-left em(14px) } } &-textarea { display block box-sizing border-box width 100% min-height em(82px) max-height em(240px) padding em(12px) color var(--default-text-color) font-size em(14px) word-wrap break-word background-color var(--fourth-text-color) border 1px solid var(--border-color) border-radius $gt-size-border-radius outline none transition all 0.25s ease resize vertical &:hover { background-color var(--background-color) } } &-preview { padding em(12px) background-color var(--background-color) border 1px solid var(--border-color) border-radius $gt-size-border-radius } &-controls { position relative margin em(12px) 0 0 clearfix() +mobile() { margin 0 } &-tip { color $gt-color-main font-size em(14px) text-decoration none vertical-align sub +mobile() { display none } } .gt-btn { float right margin-left em(20px) +mobile() { float none width 100% margin em(12px) 0 0 } } } } &:after { position fixed top 0 right 0 bottom 100% left 0 opacity 0 content '' } &.gt-input-focused { position relative &:after { position fixed top 0 right 0 bottom 0 left 0 z-index $gt-mask-z-index background #000 opacity 0.6 transition opacity 0.3s, bottom 0s content '' } .gt-header-comment { z-index $gt-mask-z-index + 1 } } // comments .gt-comments { padding-top em(20px) &-null { text-align center } &-controls { margin em(20px) 0 text-align center } } // comment .gt-comment { position relative display flex padding em(10px) 0 &-content { flex 1 margin-left em(20px) padding em(12px) em(16px) overflow auto background-color var(--second-background-color) transition all ease 0.25s +mobile() { margin-left em(14px) padding em(10px) em(12px) } } &-header { position relative margin-bottom em(8px) font-size em(14px) } &-block-1 { float right width em(32px) height em(22px) } &-block-2 { float right width em(64px) height em(22px) } &-username { color $gt-color-main font-weight 500 text-decoration none &:hover { text-decoration underline } } &-text { margin-left em(8px) color $gt-color-sub } &-date { margin-left em(8px) color $gt-color-sub } &-like &-edit &-reply { position absolute height em(22px) &:hover { cursor pointer } } &-like { top 0 right em(32px) } &-edit &-reply { top 0 right 0 } &-body { // color: $gt-color-comment-txt !important color var(--second-text-color) !important .email-hidden-toggle a { display inline-block height 12px padding 0 9px color #444d56 font-weight 600 font-size 12px line-height 6px text-decoration none vertical-align middle background #dfe2e5 border-radius 1px &:hover { background-color #c6cbd1 } } .email-hidden-reply { display none white-space pre-wrap .email-signature-reply { margin 15px 0 padding 0 15px color #586069 border-left 4px solid #dfe2e5 } } .email-hidden-reply.expanded { display block } } &-admin { .gt-comment-content { background-color var(--fourth-text-color) } } } @keyframes gt-kf-rotate { 0% { transform rotate(0) } 100% { transform rotate(360deg) } } }