1/* 2 * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16interface Mover { 17 getStatus(): { speed: number } 18} 19interface Shaker { 20 getStatus(): { frequency: number } 21} 22 23interface MoverShaker extends Mover, Shaker { 24 getStatus(): { 25 speed: number 26 frequency: number 27 } 28} 29 30class C implements MoverShaker { 31 private speed: number = 0 32 private frequency: number = 0 33 34 getStatus() { 35 return { speed: this.speed, frequency: this.frequency } 36 } 37} 38 39class MoveStatus { 40 public speed : number 41 constructor() { 42 this.speed = 0 43 } 44} 45interface Mover { 46 getMoveStatus(): MoveStatus 47} 48 49class ShakeStatus { 50 public frequency : number 51 constructor() { 52 this.frequency = 0 53 } 54} 55interface Shaker { 56 getShakeStatus(): ShakeStatus 57} 58 59class MoveAndShakeStatus { 60 public speed : number 61 public frequency : number 62 constructor() { 63 this.speed = 0 64 this.frequency = 0 65 } 66} 67 68class D implements Mover, Shaker { 69 private move_status : MoveStatus 70 private shake_status : ShakeStatus 71 72 constructor() { 73 this.move_status = new MoveStatus() 74 this.shake_status = new ShakeStatus() 75 } 76 77 public getMoveStatus() : MoveStatus { 78 return this.move_status 79 } 80 81 public getShakeStatus() : ShakeStatus { 82 return this.shake_status 83 } 84 85 public getStatus(): MoveAndShakeStatus { 86 return { 87 speed: this.move_status.speed, 88 frequency: this.shake_status.frequency 89 } 90 } 91}