Skip to content

Commit

Permalink
hi
Browse files Browse the repository at this point in the history
  • Loading branch information
ka-bear committed Jun 15, 2021
1 parent d26471e commit e9df84b
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 39 deletions.
124 changes: 124 additions & 0 deletions .idea/uiDesigner.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/main/java/Addition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
public class Addition {
/*
new file --> any name
new class --> Addition (accept 2 parameters, returns sum of 2 nums
1) test class (first)
2) write test cases for addition class
3) run test case (fails)
4) write code to make it pass
5) naming convention
6) statuc funcn --> print num of objects
7) create default constructor (print statement whenever called)
8) default destructor???? (print statement whenever called)
*/
int num1,num2,ans;
static int count=0;
public int sum(){
ans=num1+num2;
return ans;
}
public Addition() {
this.num1=0;
this.num2=0;
count+=1;
System.out.println(count+"object(s) created");
}
public Addition(int num1, int num2) {
this.num1 = num1;
this.num2 = num2;
count+=1;
System.out.println(count+" object(s) created");
}
}
24 changes: 3 additions & 21 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,9 @@

public class Main {
public static void main(String[] args) {
System.out.println("hello");
}

public static int add(int num1, int num2){
return num1+num2;
}
public static int add(int num1, int num2, int num3){
return num1+add(num2,num3);
}
public static int add(int num1, int num2, int num3,int num4){
return num1+add(num2,num3,num4);
}
public static int add(int num1, int num2, int num3,int num4, int num5){
return num1+add(num2,num3,num4,num5);
}
public static int subtract(int num1, int num2){
return num1-num2;
}
public static ArrayList<Integer> desSort(ArrayList<Integer> list){
Collections.sort(list, Collections.reverseOrder());
return list;
}
// accept array return sorted in desceding order
/*
*/
}
10 changes: 10 additions & 0 deletions src/test/java/TestAddition.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class TestAddition {
@Test
public static void main(String[] args) {
Addition x = new Addition(1,2);
assertEquals(x.sum(),3);
}
}
18 changes: 0 additions & 18 deletions src/test/java/TestMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,6 @@ public class TestMain {
@Test

public static void main(String[] args) {
assertEquals(Main.add(1,2),3);
assertEquals(Main.add(0,1,2),3);
assertEquals(Main.add(0,1,2,3),6);
assertEquals(Main.add(0,1,2,3,4),10);
assertEquals(Main.subtract(4,1),3);
ArrayList<Integer> lst = new ArrayList<Integer>();
lst.add(1);
lst.add(3);
lst.add(5);
lst.add(2);
lst.add(4);
ArrayList<Integer> lstt = new ArrayList<Integer>();
lstt.add(5);
lstt.add(4);
lstt.add(3);
lstt.add(2);
lstt.add(1);
assertEquals(Main.desSort(lst),lstt);
}

}

0 comments on commit e9df84b

Please sign in to comment.