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 16class Creature { 17 public static legs: int = 1; 18 public static brain: int = 2; 19 20 public static set Legs(l: int): void { 21 Creature.legs = l; 22 } 23 24 public static set Brain(b: int): void { 25 Creature.brain = b; 26 } 27} 28 29class Carry { 30 public static jump: int = 100; 31 public static move: int = 10; 32 33 public static get Jump(): int { 34 return Carry.jump; 35 } 36 37 public static get Move(): int { 38 return Carry.move; 39 } 40} 41 42class Glass { 43 public static size: int = 1; 44 public static transparent: int = 1; 45 46 public static set Size(s: int): void { 47 Glass.size = s; 48 } 49 50 public static get Transparent(): int { 51 return Glass.transparent; 52 } 53 54 public static get Size(): int { 55 return Glass.size; 56 } 57 58 public static set Transparent(t: int): void { 59 Glass.transparent = t; 60 } 61} 62 63function main(): void { 64 Creature.Legs = 0; 65 Creature.Brain = 3; 66 const leg = Creature.legs; 67 const brain = Creature.brain; 68 69 assert leg == 0; 70 assert brain == 3; 71 72 const jump = Carry.Jump; 73 const move = Carry.Move; 74 75 assert jump == 100; 76 assert move == 10; 77 78 Glass.Size = 150; 79 Glass.Transparent = 500; 80 81 const size = Glass.Size; 82 const transparent = Glass.Transparent; 83 84 assert size == 150; 85 assert Glass.Size == 150; 86 assert transparent == 500; 87 assert Glass.Transparent == 500; 88} 89