Power of Squares done :D
This commit is contained in:
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
||||
</state>
|
||||
</component>
|
||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -7,5 +7,46 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module-library" scope="TEST">
|
||||
<library name="JUnit4">
|
||||
<CLASSES>
|
||||
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.13.1/junit-4.13.1.jar!/" />
|
||||
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="JUnit5.8.1">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-5.8.1.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-api-5.8.1.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/opentest4j-1.2.0.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/junit-platform-commons-1.8.1.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/apiguardian-api-1.1.2.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-params-5.8.1.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/junit-jupiter-engine-5.8.1.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/junit-platform-engine-1.8.1.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="module-library">
|
||||
<library name="testng">
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/lib/testng-7.1.0.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/jcommander-1.72.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/guice-4.1.0-no_aop.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/javax.inject-1.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/aopalliance-1.0.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/guava-19.0.jar!/" />
|
||||
<root url="jar://$MODULE_DIR$/lib/snakeyaml-1.21.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
</component>
|
||||
</module>
|
||||
@@ -1,11 +1,16 @@
|
||||
package Emploice;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class Programs
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
Employees Medhat = new Employees(20);
|
||||
Employees Hamada = Medhat;
|
||||
if(Medhat.getYears() == Hamada.getYears())
|
||||
System.out.println("El dof3a be yeso7o 3ala el fady");
|
||||
Employees[] employs = new Employees[100];
|
||||
|
||||
for(int j = 0; j < employs.length; j++)
|
||||
@@ -13,12 +18,16 @@ public class Programs
|
||||
Random r = new Random();
|
||||
employs[j] = new Employees(r.nextInt(1,50));
|
||||
}
|
||||
|
||||
for(int i = 0; i < employs.length; i++)
|
||||
{
|
||||
if(employs[i].getYears() >= 20)
|
||||
System.out.println(employs[i].toString());
|
||||
}
|
||||
|
||||
//System.out.println(Arrays.toString(employs));
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
87
src/MathRelated/PowerOfSquares.java
Normal file
87
src/MathRelated/PowerOfSquares.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package MathRelated;
|
||||
|
||||
public class PowerOfSquares
|
||||
{
|
||||
public int IntegerPower(int base, int power)
|
||||
{
|
||||
|
||||
if(power == 0)
|
||||
return 1;
|
||||
|
||||
else
|
||||
{
|
||||
int count = 0;
|
||||
while (count <= power)
|
||||
{
|
||||
base = base * base;
|
||||
}
|
||||
return base;
|
||||
}
|
||||
/* else //unlucky this is not required scammed
|
||||
{
|
||||
int count = -power;
|
||||
while(count <= power)
|
||||
{
|
||||
base = base / base;
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
||||
public static void Square(int side , char c)
|
||||
{
|
||||
for (int i = 0; i < side; i++)
|
||||
{
|
||||
for (int j = 0; j < side; j++)
|
||||
{
|
||||
|
||||
System.out.print(c);
|
||||
}
|
||||
System.out.print("\n");
|
||||
|
||||
}
|
||||
}
|
||||
public static void Rectangle(int length , int width , char c)
|
||||
{
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
for (int j = 0; j < width; j++)
|
||||
{
|
||||
|
||||
System.out.print(c);
|
||||
}
|
||||
System.out.print("\n");
|
||||
|
||||
}
|
||||
}
|
||||
public static void sortarray(int[] array)
|
||||
{
|
||||
int count = 0;
|
||||
while(count < array.length)
|
||||
{
|
||||
for (int i = 0; i < array.length; i++)
|
||||
{
|
||||
if(i < array.length -2)
|
||||
{
|
||||
|
||||
if (array[i] > array[i+1])
|
||||
swap(i,i+1,array);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static void swap(int a , int b, int[] array)
|
||||
{
|
||||
int temp = 0;
|
||||
array[a] = temp;
|
||||
array[a] = array[b];
|
||||
array[b] = temp;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
63
src/MathRelated/PowerOfSquaresTest.java
Normal file
63
src/MathRelated/PowerOfSquaresTest.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package MathRelated;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
public class PowerOfSquaresTest extends PowerOfSquares
|
||||
{
|
||||
|
||||
@Test
|
||||
public void integerPower()
|
||||
{
|
||||
assertEquals(27,IntegerPower(3,3));
|
||||
assertEquals(4,IntegerPower(2,2));
|
||||
assertEquals(1,IntegerPower(2,0));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void squareTest()
|
||||
{
|
||||
Square(4,'#');
|
||||
Square(10,'a');
|
||||
Square(5,'v');
|
||||
Square(1,'c');
|
||||
Square(6,'s');
|
||||
Square(2,'o');
|
||||
Square(2,'p');
|
||||
Square(8,'l');
|
||||
Square(9,'i');
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void RectangleTest()
|
||||
{
|
||||
Rectangle(10,20,'c');
|
||||
Rectangle(10,20,'#');
|
||||
Rectangle(10,20,'@');
|
||||
Rectangle(10,20,'*');
|
||||
Rectangle(10,20,'A');
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortarrayTest()
|
||||
|
||||
{
|
||||
int[] array = new int[10];
|
||||
int[] hypothesis = {1,2,3,4,5,6,7,8,9,10};
|
||||
int filler = array.length;
|
||||
for(int i =array.length-1; i >=0; i--)
|
||||
{
|
||||
array[i] = filler;
|
||||
filler--;
|
||||
|
||||
}
|
||||
sortarray(array);
|
||||
for(int i = 0; i < hypothesis.length; i++)
|
||||
{
|
||||
assertEquals(hypothesis[i] , array[i]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -33,6 +33,7 @@ public class Product
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
||||
19
src/Products/ProductTest.java
Normal file
19
src/Products/ProductTest.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package Products;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
||||
public class ProductTest {
|
||||
|
||||
@Test
|
||||
public void checkExpiredTest()
|
||||
{
|
||||
Date d1 = new Date(2025,10,10);
|
||||
Product p1 = new Product("A1",100,d1);
|
||||
assertFalse(p1.checkExpired());
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user