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
54 changes: 27 additions & 27 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
.DS_Store
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea
*.iml
.DS_Store
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.idea
*.iml
target
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: java
jdk: openjdk17
jobs:
include:
- script: mvn clean verify package
after_success:
language: java
jdk: openjdk17
jobs:
include:
- script: mvn clean verify package
after_success:
- bash <(curl -s https://codecov.io/bash)
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
[![Build Status](https://app.travis-ci.com/sarafarag/Spring22CodeReviewActivity.svg?token=pcgRqfKGuCm9Gai24pHo&branch=main)](https://app.travis-ci.com/sarafarag/Spring22CodeReviewActivity)

@BCComputerScience

# Spr23-5540-CodeReviewActivity

## Task 1: Open a Pull request
1. **Clone/Fork** this repository that contains the unit test assignmentSkeleton from here. You should have access now, because you can see this ReadMe file.
2. If Cloned, create a branch to the local repository named "First_lastName_CodeReview"
3. Update the skeleton project with your final project implementation from Assignment two
4. Don't change the pom.xml or the .travis.yml file
5. Commit your changes to the **local repository** 
6. Push your local barnch to the remote
7. Complete a pull request for the updates


### Warning: You have to complete Task 1 to be appointed as a reviewer for a pull request and start Task 2

## Task 2: Code review for the assigned pull request
1. You will be assigned to a students' submission to complete the code review for their project implementation.
2. You need to complete the code reviews for the pull request assigned to you.
3. Check the build for the assigned code and note if there is any errors
4. If there is a build issue indiacte it in your review comments
5. Also, add at least four meaningful inline reviews of the class implementation, the test class, and one overall recap. Agreeing on the implementation is not counted as a meaningful review.
Approve or request changes to the pull request
6. Take screenshots for your reviews.

### Check Canvas for more instructions on how to ccomplete each task

Enjoy your code review experience.

Sara
[![Build Status](https://app.travis-ci.com/sarafarag/Spring22CodeReviewActivity.svg?token=pcgRqfKGuCm9Gai24pHo&branch=main)](https://app.travis-ci.com/sarafarag/Spring22CodeReviewActivity)
@BCComputerScience
# Spr23-5540-CodeReviewActivity
## Task 1: Open a Pull request
1. **Clone/Fork** this repository that contains the unit test assignmentSkeleton from here. You should have access now, because you can see this ReadMe file.
2. If Cloned, create a branch to the local repository named "First_lastName_CodeReview"
3. Update the skeleton project with your final project implementation from Assignment two
4. Don't change the pom.xml or the .travis.yml file
5. Commit your changes to the **local repository** 
6. Push your local barnch to the remote
7. Complete a pull request for the updates
### Warning: You have to complete Task 1 to be appointed as a reviewer for a pull request and start Task 2
## Task 2: Code review for the assigned pull request
1. You will be assigned to a students' submission to complete the code review for their project implementation.
2. You need to complete the code reviews for the pull request assigned to you.
3. Check the build for the assigned code and note if there is any errors
4. If there is a build issue indiacte it in your review comments
5. Also, add at least four meaningful inline reviews of the class implementation, the test class, and one overall recap. Agreeing on the implementation is not counted as a meaningful review.
Approve or request changes to the pull request
6. Take screenshots for your reviews.
### Check Canvas for more instructions on how to ccomplete each task
Enjoy your code review experience.
Sara
154 changes: 77 additions & 77 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,77 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>UnitTestAssignment</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.9</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>UnitTestAssignment</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>15</maven.compiler.source>
<maven.compiler.target>15</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.7.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M5</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.7</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
<execution>
<id>jacoco-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>PACKAGE</element>
<limits>
<limit>
<counter>LINE</counter>
<value>COVEREDRATIO</value>
<minimum>0.9</minimum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
95 changes: 62 additions & 33 deletions src/main/java/StringManipulation.java
Original file line number Diff line number Diff line change
@@ -1,33 +1,62 @@
public class StringManipulation implements StringManipulationInterface {

@Override
public String getString() {
return null;
}

@Override
public void setString(String string) {
}

@Override
public int count() {
return 0;
}

@Override
public String removeNthCharacter(int n, boolean maintainSpacing) {
return null;
}

@Override
public String[] getSubStrings(int startWord, int endWord) {
return null;
}

@Override
public String restoreString(int[] indices) {
return null;
}


}
import java.util.Arrays;

public class StringManipulation implements StringManipulationInterface {
private String value;

@Override
public String getString() {
return value;
}

@Override
public void setString(String string) {
value = string;
}

@Override
public int count() {
if (value.trim() == "") return 0;
return value.trim().split("\\s+").length;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The result of value.trim().split() is re-used several times in the code, but is calculated every time. It should be cached and regenerated whenever the string is changed.

}

@Override
public String removeNthCharacter(int n, boolean maintainSpacing) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method throws no exceptions at all!


char[] chars = value.toCharArray();
String res = "";

for (int i = 0; i < chars.length; i++) {

if ( (i+1)%n != 0 ) res += chars[i];
else if (maintainSpacing) res += " ";
}
return res;
}

@Override
public String[] getSubStrings(int startWord, int endWord){
String[] words = value.trim().split("\\s+");
if (value.trim() == "" || endWord < startWord || startWord > words.length) throw new IllegalArgumentException();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exceptions should come with messages relevant to what occurred. This is apparent in multiple places.

return Arrays.copyOfRange(value.trim().split("\\s+"), startWord-1, endWord+1);
}

@Override
public String restoreString(int[] indices) {
if (value == null || indices.length != value.length()) throw new IllegalArgumentException();

//output string
String res = "";

//string value to char array
char[] chars = value.toCharArray();

for (int index : indices) {
if (index >= 0 && index < chars.length) res += chars[index];
else throw new ArrayIndexOutOfBoundsException();
}

return res;
}


}
Loading