Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 07ff7f4

Browse files
committed
Machine class added
1 parent ac24aa3 commit 07ff7f4

File tree

3 files changed

+162
-13
lines changed

3 files changed

+162
-13
lines changed

.idea/uiDesigner.xml

Lines changed: 124 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Machine.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
public class Machine {
2+
//data declaration
3+
String name;
4+
String type;
5+
String function;
6+
//constructors
7+
8+
//no parameterized constructor
9+
Machine() {
10+
}
11+
//parameterized constructor
12+
Machine(String name) {
13+
this.name = name;
14+
}
15+
Machine(String name, String type) {
16+
this.name = name;
17+
this.type = type;
18+
}
19+
Machine(String name, String type, String function) {
20+
this.name = name;
21+
this.type = type;
22+
this.function = function;
23+
}
24+
//copy constructor
25+
Machine(Machine m1) {
26+
this.name = m1.name;
27+
this.type = m1.type;
28+
this.function = m1.function;
29+
}
30+
}

src/Main.java

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,22 @@ class Shape {
44
Shape(String colour) {
55
this.colour = colour;
66
}
7-
Shape(String colour, double area){
8-
this.colour=colour;
9-
this.area=area;
7+
Shape(String colour, double area) {
8+
this.colour = colour;
9+
this.area = area;
1010
}
11-
12-
Shape(Shape s1){
13-
this.colour=s1.colour;
14-
this.area=s1.area;
11+
Shape(Shape s1) {
12+
this.colour = s1.colour;
13+
this.area = s1.area;
1514
}
16-
17-
void findArea(){
18-
15+
void findArea() {
1916
}
20-
21-
2217
}
2318

2419
public class Main {
2520
public static void main(String[] args) {
2621
Shape s1 = new Shape("red", 2.3);
27-
Shape s2=new Shape(s1);
22+
Shape s2 = new Shape(s1);
2823
System.out.println("properties of s1");
2924
System.out.println(s1.colour);
3025
System.out.println(s1.area);

0 commit comments

Comments
 (0)