-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathExercise.java
More file actions
43 lines (27 loc) · 1.88 KB
/
Exercise.java
File metadata and controls
43 lines (27 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package com.booleanuk.core;
public class Exercise {
// A URL consists of these parts: [protocol]://[domain]/[path]
public String brokenUrl = " httpz://booLeAn.co.uk/who-we-are ";
// 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)
char target = 'z';
char replacement = 's';
public String fixedUrl = brokenUrl.replace(target, replacement);
// Here's a documentation link for all string methods, use it to figure out how to complete the rest of these requirements:
// https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/String.html#method-summary
// 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 = 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 = lowerCasedUrl.trim() ;
// 4. Using the appropriate string method on url, set the value of the protocol member below
public String protocol = url.substring(0, 5);
// 5. Using the appropriate string method on url, set the value of the domain member below
public String domain = url.substring(8,21);
// 6. Set the length member below to the length of the url member
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 = protocol + "://" + domain + "/faq";
}