Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
47 lines (32 loc) · 1.17 KB

File metadata and controls

47 lines (32 loc) · 1.17 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
public class Triangle6 extends TwoDShape6 {
private String styleString;
// A default constructor.
public Triangle6() {
// super(); Call superclass constructor.
styleString = "none";
}
/*
* If a constructor does not explicitly invoke a superclass constructor,
* the Java compiler automatically inserts a call to the no-argument constructor of the superclass.
* If the super class does not have a no-argument constructor, you will get a compile-time error.
References:
https://web.archive.org/web/20210118184134/https://docs.oracle.com/javase/tutorial/java/IandI/super.html
*/
// Constructor
Triangle6(String s, double w, double h){
// super(w, h); Use super() to call the various forms of the TwoDShape constructor.
// width = w;
styleString = s;
}
// One argument constructor.
Triangle6(double x){
// super(x); Use super() to construct the various forms of the TwoDShape constructor.
styleString = "filled";
}
double area() {
return getWidth() * getHeight() / 2;
}
void showStyle() {
System.out.println("Triangle is " + styleString);
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.