Skip to content

Commit 956bd8b

Browse files
Methods in java
1 parent cf5e3f3 commit 956bd8b

File tree

10 files changed

+133
-0
lines changed

10 files changed

+133
-0
lines changed
788 Bytes
Binary file not shown.
1.18 KB
Binary file not shown.
1.43 KB
Binary file not shown.
757 Bytes
Binary file not shown.
153 Bytes
Binary file not shown.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package Package;
2+
3+
public class MyClass {
4+
5+
public static void main(String[] args) {
6+
// mymethod(10,20);
7+
// System.out.println("--------------");
8+
// mymethod(300,200);
9+
//
10+
//
11+
// }
12+
//
13+
// public static void mymethod(int start,int stop) {
14+
// for(;start>stop;start++){
15+
// System.out.println(start);
16+
// break;
17+
// }
18+
//
19+
20+
int n = 345678;
21+
22+
switch(n) {
23+
case 1:
24+
System.out.println("will you print case1");
25+
break;
26+
case 2:
27+
System.out.println("will you print case2");
28+
break;
29+
case 3:
30+
System.out.println("Will you print case3");
31+
break;
32+
default:
33+
System.out.println("offcause I'm your last option");
34+
}
35+
36+
}
37+
38+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package literals;
2+
3+
public class Day7 {
4+
5+
6+
public static void main(String[] args) {
7+
//Boolean is one kind of literals
8+
Boolean b = true;
9+
int a = 011;
10+
System.out.println("So our literals is: " + b + "" + a);
11+
12+
13+
}
14+
15+
16+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package methods;
2+
3+
public class Cars {
4+
5+
private String doors;
6+
private String engine;
7+
private String drivers;
8+
private int speed;
9+
10+
11+
public Cars(String doors, String engine, String drivers, int speed) {
12+
// TODO Auto-generated constructor stub
13+
}
14+
public String getDoors() {
15+
return doors;
16+
}
17+
public void setDoors(String doors) {
18+
this.doors = doors;
19+
}
20+
public String getEngine() {
21+
return engine;
22+
}
23+
public void setEngine(String engine) {
24+
this.engine = engine;
25+
}
26+
public String getDrivers() {
27+
return drivers;
28+
}
29+
public void setDrivers(String drivers) {
30+
this.drivers = drivers;
31+
}
32+
public int getSpeed() {
33+
return speed;
34+
}
35+
public void setSpeed(int speed) {
36+
this.speed = speed;
37+
}
38+
39+
public String run() {
40+
if(doors.equals("closed") && drivers.equals("seated")
41+
&& engine.equals("on") && speed > 0) {
42+
return "running";
43+
} else {
44+
return "Not running";
45+
}
46+
47+
48+
}
49+
50+
51+
52+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package methods;
2+
3+
public class ImportedClass1 {
4+
5+
public static void main(String[] args) {
6+
Cars c = new Cars("closed","on","seated",50);
7+
// c.setDoors("closed");
8+
// c.setDrivers("sitting");
9+
// c.setSpeed(50);
10+
// c.setEngine("on");
11+
//
12+
System.out.println(c.run());
13+
// System.out.println(c.getEngine());
14+
15+
16+
}
17+
18+
19+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
*
3+
*/
4+
/**
5+
*
6+
*/
7+
module PraticeProject {
8+
}

0 commit comments

Comments
 (0)