-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathdrawTriangle.java
More file actions
55 lines (35 loc) · 937 Bytes
/
drawTriangle.java
File metadata and controls
55 lines (35 loc) · 937 Bytes
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
import java.util.*;
class MyTriangle {
private int length;
public MyTriangle(){
this.setLength(length);
}
public MyTriangle(int length){
this.setLength(length);
}
public void setLength(int length) {
this.length = length;
}
public int getLength() {
return this.length;
}
public void draw(){
for (int b = 0; b <= this.length; b++){
for (int c = 1; c <= b; c++) {
System.out.print('*');
}
System.out.println();
}
}
}
class Main {
public static void main(String[] args){
System.out.println("Input the Length: ");
Scanner scanner = new Scanner(System.in);
int length = scanner.nextInt();
System.out.println("Output: ");
MyTriangle t = new MyTriangle();
t.setLength( length );
t.draw();
}
}