Skip to content
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
39 changes: 39 additions & 0 deletions src/main/java/com/dtcc/exams/part1/DelTechConcatenator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.dtcc.exams.part1;

public class DelTechConcatenator {

Integer valueToTest;

public DelTechConcatenator(){
this.valueToTest = null;
}

public DelTechConcatenator(Integer value){
this.valueToTest = value;
}

public boolean isDel(){
boolean result = false;
if(valueToTest % 3 == 0){
result = true;
}
return result;
}

public boolean isTech(){
boolean result = false;
if(valueToTest % 5 == 0){
result = true;
}
return result;
}

public boolean isDelTech(){
boolean result = false;
if(isDel() == true && isTech() == true){
result = true;
}
return result;
}

}
7 changes: 7 additions & 0 deletions src/main/java/com/dtcc/exams/part2/arrayUtility.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.dtcc.exams.part2;

public class arrayUtility {



}
30 changes: 30 additions & 0 deletions src/main/java/com/dtcc/exams/part3/RockPaperScissors.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.dtcc.exams.part3;

public enum RockPaperScissors {ROCK, PAPER, SCISSORS;

RockPaperScissors(){}

public RockPaperScissors getWinningSign(){
if(this.equals(ROCK)) {
return PAPER;
}
else if(this.equals(PAPER)) {
return SCISSORS;
}
else{
return ROCK;
}
}

public RockPaperScissors getLosingSign(){
if(this.equals(ROCK)) {
return SCISSORS;
}
else if(this.equals(PAPER)) {
return ROCK;
}
else{
return PAPER;
}
}
}
36 changes: 35 additions & 1 deletion src/main/java/com/dtcc/exams/part4/Geometry.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
package com.dtcc.exams.part4;

public class Geometry {
public class Geometry implements Rectangle, Circle {

Integer height;
Integer width;
Integer radius;

public Geometry() {
this.height = 0;
this.width = 0;
this.radius = 0;
}

public Geometry(Integer height, Integer width, Integer radius) {
this.height = height;
this.width = width;
this.radius = radius;
}

public int area(int height, int width) {
return height * width;
}

public double area(int radius) {
return (3.14 * (radius * radius));
}

public int getArea(Integer height, Integer width) {
return area(height, width);
}

public double getArea(Integer radius) {
return area(radius);
}
}


32 changes: 32 additions & 0 deletions src/main/java/com/dtcc/exams/part5/ElectionLand.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
package com.dtcc.exams.part5;

import java.util.Map;
import java.util.TreeMap;

public class ElectionLand {

public Map<String, Integer> votesTallied;

//should put it in alphabetical order...not sure why it's not working
public ElectionLand(){
votesTallied = new TreeMap<>();
}

public String electionWinner(String[] votes){
String winner = null;
int tempHighest = 0;
for(int i =0; i<votes.length; i++) {
if(votesTallied.containsKey(votes[i])){
int j = votesTallied.get(votes[i]) +1;
votesTallied.put(votes[i], j);
}
else{
votesTallied.put(votes[i], 1);
}
}

for(String name : votes) {
if (votesTallied.get(name) >= tempHighest){
tempHighest = votesTallied.get(name);
winner = name;
}
}
return winner;
}
}
21 changes: 21 additions & 0 deletions src/main/java/com/dtcc/exams/part6/LoveLetter.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,25 @@
package com.dtcc.exams.part6;

public class LoveLetter {

public Integer[] mystery(String[] input){
int length = input.length;
Integer[] result = new Integer[length];

for(int i = 0; i< length; i++){
String str = input[i];
int count = 0;

int left = 0;
int right = str.length() -1;

while (left < right){
count += Math.abs(str.charAt(left) - str.charAt(right));
left++;
right--;
}
result[i] = count;
}
return result;
}
}
33 changes: 33 additions & 0 deletions src/main/java/com/dtcc/exams/part7/FindTheWinner.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.dtcc.exams.part7;

public class FindTheWinner {

private String winner;

public String winner(Integer[] Zan, Integer[] Brian, String s) {
int player1Score = 0;
int player2Score = 0;
String winner = "Tie";

for(int i = 0; i< Brian.length; i++){
if(i%2 == 0 && s.equals("Even")) {
player1Score += Zan[i] - Brian[i];
player2Score += Brian[i] - Zan[i];
}
else if(i%2 != 0 && s.equals("Odd")){
player1Score += Zan[i] - Brian[i];
player2Score += Brian[i] - Zan[i];
}
}

if(player1Score > player2Score){
winner = "Zan";
}
else if(player1Score < player2Score){
winner = "Brian";
}

return winner;
}

}
11 changes: 11 additions & 0 deletions src/main/main.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
7 changes: 3 additions & 4 deletions src/test/java/com/dtcc/exams/assessment/ProjectTestSuite.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package com.dtcc.exams.assessment;
/*

import com.dtcc.exams.assessment.part1.DelTechConcatenatorTest;
import com.dtcc.exams.assessment.part2.ArrayUtilityTestSuite;
//import com.dtcc.exams.assessment.part2.ArrayUtilityTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

@RunWith(Suite.class)

@Suite.SuiteClasses({
ArrayUtilityTestSuite.class,
//ArrayUtilityTestSuite.class,
DelTechConcatenatorTest.class,
})
public class ProjectTestSuite {
}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dtcc.exams.assessment.part3;
/*

import com.dtcc.exams.part3.RockPaperScissors;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -24,4 +25,3 @@ public void evaluateLoserTest() {
Assert.assertEquals(expected, actual);
}
}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dtcc.exams.assessment.part3;
/*

import com.dtcc.exams.part3.RockPaperScissors;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -24,4 +25,3 @@ public void evaluateLoserTest() {
Assert.assertEquals(expected, actual);
}
}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.dtcc.exams.assessment.part3;
/*

import org.junit.runner.RunWith;
import org.junit.runners.Suite;

Expand All @@ -12,4 +12,3 @@
})
public class RockPaperScissorTestSuite {
}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dtcc.exams.assessment.part3;
/*

import com.dtcc.exams.part3.RockPaperScissors;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -24,4 +25,3 @@ public void evaluateLoserTest() {
Assert.assertEquals(expected, actual);
}
}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.dtcc.exams.assessment.part4;
/*

import com.dtcc.exams.part4.Geometry;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -81,4 +81,3 @@ public int compare(Class o1, Class o2) {
}

}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.dtcc.exams.assessment.part5;
/*

import com.dtcc.exams.part5.ElectionLand;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -49,4 +49,3 @@ public void electionWinnerTest4(){
}

}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.dtcc.exams.assessment.part6;
/*

import com.dtcc.exams.part6.LoveLetter;
import org.junit.Assert;
import org.junit.Test;
Expand Down Expand Up @@ -45,4 +45,3 @@ public void mysteryTest3(){
}

}
*/
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.dtcc.exams.assessment.part7;
/*

import com.dtcc.exams.part7.FindTheWinner;
import org.junit.Assert;
import org.junit.Test;

Expand Down Expand Up @@ -28,4 +29,3 @@ public void winnerTest2(){
}

}
*/
11 changes: 11 additions & 0 deletions src/test/test.iml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>