@@ -7,7 +7,7 @@ public class Exercise {
7
7
// 1. The brokenUrl member above contains an invalid URL. There's a z instead of an s in the protocol (httpz instead of https).
8
8
// Using the `replace` method on brokenUrl, set the fixedUrl member below to the correct value.
9
9
// https://docs.oracle.com/en/java/javase/18/docs/api/java.base/java/lang/String.html#replace(char,char)
10
- public String fixedUrl = "" ;
10
+ public String fixedUrl = brokenUrl . replace ( 'z' , 's' ) ;
11
11
12
12
13
13
// Here's a documentation link for all string methods, use it to figure out how to complete the rest of these requirements:
@@ -16,26 +16,26 @@ public class Exercise {
16
16
17
17
// 2. There are currently some upper case characters in the URL. Using an appropriate string method on the fixedUrl member above,
18
18
// set the value of lowerCasedUrl.
19
- public String lowerCasedUrl = "" ;
19
+ public String lowerCasedUrl = fixedUrl . toLowerCase () ;
20
20
21
21
22
22
// 3. There is still white space on both ends of the URL! Use the appropriate string method to trim that white space
23
23
// and set the value of the url member below
24
- public String url = "" ;
24
+ public String url = lowerCasedUrl . strip () ;
25
25
26
26
27
27
// 4. Using the appropriate string method on url, set the value of the protocol member below
28
- public String protocol = "" ;
28
+ public String protocol = url . substring ( 0 , 5 ) ;
29
29
30
30
31
31
// 5. Using the appropriate string method on url, set the value of the domain member below
32
- public String domain = "" ;
32
+ public String domain = url . substring ( 8 , 21 ) ;
33
33
34
34
35
35
// 6. Set the length member below to the length of the url member
36
- public int length = 0 ;
36
+ public int length = url . length () ;
37
37
38
38
39
39
// 7. Using concatenation and existing members, set the faqUrl member below to the faq page of the boolean website
40
- public String faqUrl = " " ;
40
+ public String faqUrl = protocol + "://" + domain + "/faq " ;
41
41
}
0 commit comments