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
171 changes: 19 additions & 152 deletions package.bluej
Original file line number Diff line number Diff line change
@@ -1,164 +1,31 @@
#BlueJ package file
dependency1.from=StringUtilsConcatenateTest
dependency1.to=StringUtilities
dependency1.type=UsesDependency
dependency2.from=StringUtilsReverseTest
dependency2.to=StringUtilities
dependency2.type=UsesDependency
dependency3.from=LoopsFunAcronymTest
dependency3.to=LoopFun
dependency3.type=UsesDependency
dependency4.from=StringUtilsGetLastWordTest
dependency4.to=StringUtilities
dependency4.type=UsesDependency
dependency5.from=StringUtilsRemoveCharacterTest
dependency5.to=StringUtilities
dependency5.type=UsesDependency
dependency6.from=MathUtilitiesIsOddTest
dependency6.to=MathUtilities
dependency6.type=UsesDependency
dependency7.from=MathUtilitiesAddTest
dependency7.to=MathUtilities
dependency7.type=UsesDependency
dependency8.from=MathUtilitiesSquareTest
dependency8.to=MathUtilities
dependency8.type=UsesDependency
dependency9.from=MathUtilitiesHalfTest
dependency9.to=MathUtilities
dependency9.type=UsesDependency
editor.fx.0.height=722
editor.fx.0.width=876
editor.fx.0.x=158
editor.fx.0.y=115
objectbench.height=142
editor.fx.0.height=0
editor.fx.0.width=0
editor.fx.0.x=0
editor.fx.0.y=0
objectbench.height=141
objectbench.width=1416
package.divider.horizontal=0.6
package.divider.vertical=0.8023872679045093
package.editor.height=598
package.editor.width=1298
package.divider.vertical=0.8021390374331551
package.editor.height=593
package.editor.width=1324
package.editor.x=0
package.editor.y=23
package.editor.y=33
package.frame.height=812
package.frame.width=1440
package.numDependencies=9
package.numTargets=16
package.numDependencies=0
package.numTargets=1
package.showExtends=true
package.showUses=true
project.charset=UTF-8
readme.height=58
readme.height=60
readme.name=@README
readme.width=47
readme.width=48
readme.x=10
readme.y=10
target1.height=50
target1.name=StringUtilsConcatenateTest
target1.showInterface=false
target1.type=UnitTestTargetJunit4
target1.width=200
target1.x=250
target1.y=420
target10.height=50
target10.name=StringUtilsReverseTest
target10.showInterface=false
target10.type=UnitTestTargetJunit4
target10.width=170
target10.x=250
target10.y=300
target11.height=50
target11.name=StringUtilsRemoveCharacterTest
target11.showInterface=false
target11.type=UnitTestTargetJunit4
target11.width=230
target11.x=250
target11.y=480
target12.height=50
target12.name=MathUtilitiesHalfTest
target12.showInterface=false
target12.type=UnitTestTargetJunit4
target12.width=160
target12.x=20
target12.y=250
target13.height=50
target13.name=LoopsFunAcronymTest
target13.showInterface=false
target13.type=UnitTestTargetJunit4
target13.width=170
target13.x=530
target13.y=460
target14.height=50
target14.name=StringUtilities
target14.showInterface=false
target14.type=ClassTarget
target14.width=110
target14.x=400
target14.y=180
target15.height=50
target15.name=StringUtilsGetMiddleCharacterTest
target15.showInterface=false
target15.type=UnitTestTargetJunit4
target15.width=240
target15.x=250
target15.y=540
target16.height=50
target16.name=StringUtilsReturnInput
target16.showInterface=false
target16.type=UnitTestTargetJunit4
target16.width=160
target16.x=250
target16.y=240
target2.height=50
target2.name=LoopFunEncryptTest
target2.showInterface=false
target2.type=UnitTestTargetJunit4
target2.width=160
target2.x=540
target2.y=340
target3.height=50
target3.name=LoopFun
target3.showInterface=false
target3.type=ClassTarget
target3.width=80
target3.x=480
target3.y=280
target4.height=50
target4.name=MathUtilitiesAddTest
target4.showInterface=false
target4.type=UnitTestTargetJunit4
target4.width=160
target4.x=20
target4.y=310
target5.height=50
target5.name=MathUtilities
target5.showInterface=false
target5.type=ClassTarget
target5.width=100
target5.x=130
target5.y=190
target6.height=50
target6.name=StringUtilsGetLastWordTest
target6.showInterface=false
target6.type=UnitTestTargetJunit4
target6.width=200
target6.x=250
target6.y=360
target7.height=50
target7.name=LoopFunFactorialTest
target7.showInterface=false
target7.type=UnitTestTargetJunit4
target7.width=160
target7.x=540
target7.y=400
target8.height=50
target8.name=MathUtilitiesIsOddTest
target8.showInterface=false
target8.type=UnitTestTargetJunit4
target8.width=170
target8.x=20
target8.y=370
target9.height=50
target9.name=MathUtilitiesSquareTest
target9.showInterface=false
target9.type=UnitTestTargetJunit4
target9.width=180
target9.x=20
target9.y=430
target1.height=70
target1.name=README.md
target1.type=TextTarget
target1.width=120
target1.x=70
target1.y=10
26 changes: 22 additions & 4 deletions src/main/java/LoopFun.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import java.util.Locale;

public class LoopFun
{
Expand All @@ -10,7 +10,11 @@ public class LoopFun
* @return the factorial of the number
*/
public Integer factorial(Integer number){
return null;
int factor = 1;
for(int i = 1; i<=number; i++){
factor = factor * i;
}
return factor;
}

/**
Expand All @@ -21,7 +25,11 @@ public Integer factorial(Integer number){
* @return Upper case string of the first letter of each word
*/
public String acronym(String phrase) {
return null;
String initials = "";
for (String s : phrase.split(" ")){
initials += s.charAt(0);
}
return initials.toUpperCase();
}

/**
Expand All @@ -37,6 +45,16 @@ public String acronym(String phrase) {
* @return the encrypted string by shifting each character by three character
*/
public String encrypt(String word) {
return null;
String s = "";
int shift = 3;
int len = word.length();
for (int i = 0; i < len; i++){
char c = (char)(word.charAt(i)+ shift);
if (c> 'z')
s += (char)(word.charAt(i)-(26-shift));
else
s += (char)(word.charAt(i)+shift);
}
return s;
}
}
23 changes: 18 additions & 5 deletions src/main/java/MathUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ public class MathUtilities{
* @return the sum of the two numbers
*/
public Integer add(Integer baseValue, Integer valueToAdd){
return null;

int sum;
sum = baseValue + valueToAdd;
return sum;
}

/**
Expand All @@ -19,7 +22,9 @@ public Integer add(Integer baseValue, Integer valueToAdd){
* @return the sum of the two numbers
*/
public Double add(Double baseValue, Double valueToAdd){
return null;
double sum;
sum = baseValue + valueToAdd;
return sum;
}

/**
Expand All @@ -28,7 +33,9 @@ public Double add(Double baseValue, Double valueToAdd){
* @return the half of the number in double
*/
public Double half(Integer number) {
return null;
double half;
half = number/2;
return half;
}

/**
Expand All @@ -37,7 +44,11 @@ public Double half(Integer number) {
* @return true if the number is odd, false if it is even
*/
public Boolean isOdd(Integer number){
return null;

if(number%2 == 0) {
return false;
}
return true;
}


Expand All @@ -47,7 +58,9 @@ public Boolean isOdd(Integer number){
* @return the result of the number multiply by itself
*/
public Integer square(Integer number) {
return null;
int squared;
squared = number * number;
return squared;
}

}
33 changes: 27 additions & 6 deletions src/main/java/StringUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ public class StringUtilities {
* @return `input`
*/
public String returnInput(String input) {
return null;


return input;
}

/**
Expand All @@ -14,23 +16,35 @@ public String returnInput(String input) {
* @return the concatenation of `baseValue` and `valueToBeAdded`
*/
public String concatenate(String baseValue, String valueToBeAdded) {
return null;

return baseValue + valueToBeAdded;
}

/**
* @param valueToBeReversed value to be reversed
* @return identical string with characters in opposite order
*/
public String reverse(String valueToBeReversed) {
return null;

String rString = "";
char ch;
for (int i = 0; i < valueToBeReversed.length(); i++){
ch = valueToBeReversed.charAt(i);
rString = ch + rString;
}
return rString;
}

/**
* @param word word to get middle character of
* @return middle character of `word`
*/
public Character getMiddleCharacter(String word) {
return null;

int len = word.length();
int middle = len/2;

return word.charAt(middle);
}

/**
Expand All @@ -39,14 +53,21 @@ public Character getMiddleCharacter(String word) {
* @return `value` with char of value `charToRemove` removed
*/
public String removeCharacter(String value, Character charToRemove) {
return null;


String s = "" + charToRemove;
String replace = "";
String strNew = value.replace(s, replace);
return strNew;
}

/**
* @param sentence String delimited by spaces representative of a sentence
* @return last `word` in sentence
*/
public String getLastWord(String sentence) {
return null;

String lastWord1 = sentence.substring(sentence.lastIndexOf(" ")+1);
return lastWord1;
}
}