1/* 2 * Copyright (c) 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 A { 17 a: int = 1; 18 b: int = 3; 19 public constructor() { 20 this.a = 2; 21 this.b = 4; 22 this.a = 10; 23 this.b = 20; 24 } 25 26 public constructor(p : int) { 27 this(); 28 this.a = 30; 29 this.b = 40; 30 } 31 32 public constructor(s : String) { 33 this.a = 2; 34 this.b = 4; 35 this.a = 50; 36 this.b = 60; 37 } 38 39} 40 41class B extends A { 42 c: int = 11; 43 d: int = 33; 44 public constructor() { 45 this.c += 22; 46 this.d -= 44; 47 this.c = 100; 48 this.d = 200; 49 } 50 51 public constructor(p : int) { 52 this(); 53 this.c = 300; 54 this.d = 400; 55 } 56 57 public constructor(s : String) { 58 super(0); 59 this.c += 22; 60 this.d -= 44; 61 this.c = 500; 62 this.d = 600; 63 } 64 65} 66