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
35 changes: 35 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,35 @@
package com.dtcc.exams.part1;

import java.util.ArrayList;
import java.util.Scanner;

public class DelTechConcatenator {


Integer input;

public DelTechConcatenator(Integer input) {
this.input = input;
}

public Boolean isDel(){
if(input % 3 == 0){
return true;
}else
return false;
}

public Boolean isTech(){
if(input % 5 == 0){
return true;
}else
return false;
}

public Boolean isDelTech(){
if(input % 3 == 0 && input % 5 == 0){
return true;
}else
return false;
}
}
27 changes: 27 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,27 @@
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;
}
}
43 changes: 42 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,45 @@
package com.dtcc.exams.part4;

public class Geometry {
public class Geometry implements Rectangle, Circle {
private int height;
private int width;
private int radius;

@Override
public int area(int height, int width) {
return 0;
}

@Override
public double area(int radius) {
return 0;
}

public Geometry(){}

public int getHeight() {
return height;
}

public int getWidth() {
return width;
}

public int getRadius() {
return radius;
}

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

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

public double getArea(int radius){
return 3.14 *(radius * radius);
}
}
33 changes: 33 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,37 @@
package com.dtcc.exams.part5;

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

public class ElectionLand {

public static Map<String, Integer> result;

public ElectionLand() {
result = new TreeMap<>();
}

public static String electionWinner(String[] votes) {
int totalNum = 0;
String winner = null;

for (String person : votes) {
if (result.keySet().contains(person)) {
result.replace(person, result.get(person) + 1);
} else
result.put(person, 1);
}

for (Map.Entry<String, Integer> entry : result.entrySet()) {
String key = entry.getKey();
Integer value = entry.getValue();
if (value >= totalNum){
totalNum = value;
winner = key;
}
// else if(value == totalNum && winner.compareTo(key) > 0)
// winner = key;
}
return winner;
}
}
20 changes: 20 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,24 @@
package com.dtcc.exams.part6;

public class LoveLetter {
public Integer[] mystery(String[] input) {
int len = input.length;
Integer[] letter = new Integer[input.length];

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

int j = 0;
int charLen = str.length() -1;

while (j < charLen) {
count += Math.abs(str.charAt(j) - str.charAt(charLen));
j++;
charLen--;
}
letter[i] = count;
}
return letter;
}
}