• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 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
16declare function print(str:any):string;
17var arrayIterator = ['fifth', 'sixth', 666];
18print(arrayIterator[0]);
19print(arrayIterator[1]);
20print(arrayIterator[2]);
21
22class Index {
23    currentArrays: number[][] = [
24        [0, 0, 0, 0],
25        [0, 0, 0, 0],
26        [0, 0, 0, 0],
27        [0, 0, 0, 0]
28      ]
29
30    changeCurretArrays() {
31        let newArrays = [
32            [0, 0, 0, 0],
33            [0, 0, 0, 0],
34            [0, 0, 0, 0],
35            [0, 0, 0, 0]
36        ]
37
38        for (let j = 0; j < 4; j++) {
39            for (let i = 0; i < 4; i++) {
40                newArrays[j][i] = this.currentArrays[j][i] + 1;
41            }
42        }
43        return newArrays;
44    }
45
46    computeScore(array) {
47        let total = 0;
48        for (let j = 0; j < 4; j++) {
49            for (let i = 0; i < 4; i++) {
50                total  += array[j][i];
51            }
52        }
53        return total;
54    }
55
56    run() {
57        let newArray = this.changeCurretArrays();
58        print(this.computeScore(newArray));
59        print(this.computeScore(this.currentArrays));
60        this.currentArrays = newArray;
61    }
62}
63
64let index = new Index;
65for (let i = 0; i < 3; i++) {
66    index.run();
67}
68
69let K:number[] = [];
70K.push(8.2);
71print(K[0]);
72K[1] = 3;
73print(K[1]);
74
75let x = 1.2;
76let y = 9;
77let T:number[] = [0, 1, 1.2, x];
78print(T[0]);
79print(T[1]);
80print(T[2]);
81print(T[3]);
82x = 1;
83let Ta:number[] = [,, 4.2, x];
84let Tb:number[] = [1, y, 1.2, x];
85let Tc:number[] = [-2, -9, 8.3, x];
86
87print(Ta[0]);
88print(Ta[1]);
89print(Ta[2]);
90print(Ta[3]);
91
92print(Tb[0]);
93print(Tb[1]);
94print(Tb[2]);
95print(Tb[3]);
96
97print(Tc[0]);
98print(Tc[1]);
99print(Tc[2]);
100print(Tc[3]);
101
102let z = {test: 1.8}
103
104let Td:number[] = [8848, "aotTest", z, x];
105
106print(Td[0]);
107print(Td[1]);
108print(Td[2].test);
109print(Td[3]);
110
111Td[4] = 9999;
112print(Td[4]);