Skip to content
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

Hikmet Yuksek #91

Open
wants to merge 3 commits into
base: main
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
16 changes: 7 additions & 9 deletions src/main/java/com/booleanuk/core/Exercise.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class Exercise {
// 1. The brokenUrl member above contains an invalid URL. There's a z instead of an s in the protocol (httpz instead of https).
// Using the `replace` method on brokenUrl, set the fixedUrl member below to the correct value.
// https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/String.html#replace(char,char)
public String fixedUrl = "";
public String fixedUrl = brokenUrl.replace("httpz", "https");


// Here's a documentation link for all string methods, use it to figure out how to complete the rest of these requirements:
Expand All @@ -16,26 +16,24 @@ public class Exercise {

// 2. There are currently some upper case characters in the URL. Using an appropriate string method on the fixedUrl member above,
// set the value of lowerCasedUrl.
public String lowerCasedUrl = "";
public String lowerCasedUrl = fixedUrl.toLowerCase();


// 3. There is still white space on both ends of the URL! Use the appropriate string method to trim that white space
// and set the value of the url member below
public String url = "";
public String url = lowerCasedUrl.trim();


// 4. Using the appropriate string method on url, set the value of the protocol member below
public String protocol = "";
public String protocol = url.split("://")[0];


// 5. Using the appropriate string method on url, set the value of the domain member below
public String domain = "";


public String domain = url.split("://")[1].split("/")[0];
// 6. Set the length member below to the length of the url member
public int length = 0;
public int length = url.length();


// 7. Using concatenation and existing members, set the faqUrl member below to the faq page of the boolean website
public String faqUrl = "";
public String faqUrl = "https://".concat(domain).concat("/faq");
}
14 changes: 7 additions & 7 deletions src/main/java/com/booleanuk/extension/Extension.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ public StringBuilder one() {

// 1. Using the sb variable above, add "Hello, world!" to the StringBuilder
// WRITE YOUR CODE BETWEEN THIS LINE...


sb.append("Hello, world!");

// ...AND THIS LINE

Expand All @@ -42,7 +41,8 @@ public StringBuilder two() {
// 1. Using the sb variable above, add "Hello, world!" to the StringBuilder
// 2. After adding the message, use an appropriate StringBuilder method to reverse it
// WRITE YOUR CODE BETWEEN THIS LINE...

sb.append("Hello, world!");
sb.reverse();


// ...AND THIS LINE
Expand All @@ -56,8 +56,8 @@ public StringBuilder three() {
// 1. Using the sb variable above, add "Hello, world!" to the StringBuilder
// 2. After adding the message, remove the comma.
// WRITE YOUR CODE BETWEEN THIS LINE...


sb.append("Hello, world!");
sb.deleteCharAt(sb.indexOf(","));

// ...AND THIS LINE

Expand All @@ -70,8 +70,8 @@ public StringBuilder four() {
// 1. Using the sb variable above, add "Hello, world!" to the StringBuilder
// 2. After adding the message, replace the word "world" with the word "Java"
// WRITE YOUR CODE BETWEEN THIS LINE...


sb.append("Hello, world!");
sb.replace(sb.indexOf("world"), sb.indexOf("world") + "world".length(), "Java");

// ...AND THIS LINE

Expand Down
Loading