Добрый день, помогите.
package com.javarush.task.pro.task09.task0912;
/*
Проверка URL-адреса
*/
public class Solution {
public static void main(String[] args) {
String[] urls = {"https://javarush.ru", "https://google.com", "http://wikipedia.org", "facebook.com", "https://instagram", "codegym.cc"};
for (String url : urls) {
String protocol = checkProtocol(url);
String domain = checkDomain(url);
System.out.println("У URL-адреса - " + url + ", сетевой протокол - " + protocol + ", домен - " + domain);
}
}
public static String checkProtocol(String url) {
//напишите тут ваш код
url = "https://javarush.ru\", \"https://google.com\", \"http://wikipedia.org\", \"facebook.com\", \"https://instagram\", \"codegym.cc";
char[] chars = url.toCharArray();
if (url.endsWith("ttp://") || url.endsWith("http://")) {
return "http";
} else if (url.endsWith("ttps") || url.endsWith("https")) {
return "https";
} else { return "неизвестный"; }
}
public static String checkDomain(String url) {
//напишите тут ваш код
url = "https://javarush.ru\", \"https://google.com\", \"http://wikipedia.org\", \"facebook.com\", \"https://instagram\", \"codegym.cc";
char[] chars = url.toCharArray();
if (url.endsWith(".r") || url.endsWith(".ru")) {
return "ru";
} else if (url.endsWith(".co") || url.endsWith(".com")) {
return "com";
} else if (url.endsWith(".cc")) {
return "cc";
} else { return "неизвестный"; }
}
}