Skip to content

Exercise One #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
12 changes: 12 additions & 0 deletions src/main/java/com/serenitydojo/HelloWorldWriter.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.serenitydojo;

public class HelloWorldWriter {

public void writeHelloWorld() {
System.out.println("Hello World!");

}



}
25 changes: 25 additions & 0 deletions src/test/java/com/serenitydojo/HelloWorldWriterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.serenitydojo;

import org.junit.Test;

public class HelloWorldWriterTest {

@Test
public void shouldwriteHelloWorldToTheConsole() {
HelloWorldWriter writer = new HelloWorldWriter();
writer.writeHelloWorld();

}

@Test
public void declaringNumericalVariables() {

int ageThisYear = 42;

int ageNextYear = ageThisYear + 3;

System.out.println("age =" + ageNextYear);
}


}
67 changes: 67 additions & 0 deletions src/test/java/com/serenitydojo/NewExercise.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.serenitydojo;

import org.junit.Test;

public class NewExercise {
@Test
public void convertToLowerCase(){
//Converting to lower case
String bookTitle = "THE CAT IN THE HAT";

String lowerCaseTitle = bookTitle.toLowerCase();

System.out.println(lowerCaseTitle);

}

@Test
public void convertToUpperCase(){
//Converting to upper case
String bookTitle = "the cat in the hat";

String upperCaseTitle = bookTitle.toUpperCase();

System.out.println(upperCaseTitle);
}

@Test
public void trimExtraSpace(){
//Trim extra space

String bookTitle = " The Cat In The Hat ";

String str = " The Cat In The Hat ";

System.out.println(str);

System.out.println(str.trim());

}

@Test
public void findingTheLengthOfaString(){
// Finding The Length Of A String

String bookTitle = "The Cat In The Hat";

int stringSize= bookTitle.length();

System.out.println(bookTitle);

}


@Test
public void replacingTextInAstring() {
//Replacing text in a string

String bookTitle= "The Cat In The Hat";

String updatedTitle = bookTitle.replace("Hat", "Basket");

System.out.println(updatedTitle);

}


}