Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

q2,q3,q4 and their runner classes #44

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions RadhikaKhanna_500086925/question 3/MotorBike.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.in28minutes.oops;

public class MotorBike {
private int speed;

public int getSpeed() {
return speed;
}

public void setSpeed(int speed){
if (speed >0)
this.speed=speed;
}

public void increaseSpeed( int howMuch) {
this.speed=this.speed+howMuch;
}

public void decreaseSpeed( int howMuch) {
this.speed=this.speed-howMuch;
}

void start() {
System.out.println("bike started");
}

}
1 change: 1 addition & 0 deletions RadhikaKhanna_500086925/question 3/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Create a class called motorbike and adjust the speed using getters and setters
43 changes: 43 additions & 0 deletions RadhikaKhanna_500086925/question 4/Number.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.in28minutes.oops;

public class Number {

private int no1;
private int no2;



public int getNo1() {
return no1;
}

public void setNo1(int no1) {
this.no1 = no1;
}

public int getNo2() {
return no2;
}

public void setNo2(int no2) {
this.no2 = no2;
}

Number(int no1, int no2){
this.no1=no1;
this.no2=no2;
}

public int add() {
return no1+no2;
}

public int multiply() {
return no1*no2;
}

public void doubleValue() {
this.no1=this.no1*2;
this.no2=this.no2*2;
}
}
1 change: 1 addition & 0 deletions RadhikaKhanna_500086925/question 4/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create a number class and perform operations like add multiply and double on it
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.in28minutes.firstjavaproject;

public class multiplicationTableRunner {

public static void main(String[] args){
multiplicationTable table= new multiplicationTable();
table.print(6,11,15);


}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Runner class for multiplication table
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.in28minutes.oops;

public class MotorbikeRunner2 {

public static void main(String[] args) {
MotorBike honda=new MotorBike();
MotorBike bullet=new MotorBike();

bullet.start();
honda.start();

bullet.setSpeed(60);
honda.setSpeed(80);


bullet.decreaseSpeed(20);
honda.increaseSpeed(200);

System.out.println(bullet.getSpeed());
System.out.println(honda.getSpeed());


}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Runner class for motorbike
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.in28minutes.oops;

public class NumberRunner {

public static void main(String[] args) {
Number numberr=new Number(4,5);
System.out.println(numberr.add());
System.out.println(numberr.multiply());
numberr.doubleValue();
System.out.println(numberr.getNo1());
System.out.println(numberr.getNo2());

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
runner class for question 4