import java.net.*;
public class HomePage {
String owner;
URL address;
String category = "none";
public HomePage(String inOwner, String inAddress)
throws MalformedURLException {
// try{
owner = inOwner;
address = new URL(inAddress);
// }
// catch (MalformedURLException e){
// System.out.println("Error: " + e.getMessage());
// }
}
public HomePage(String inOwner, String inAddress, String inCategory)
throws MalformedURLException {
this(inOwner, inAddress);
category = inCategory;
}
}
import java.net.*;
public class PageCatalog {
public static void main(String[] arguments) throws Exception {
HomePage[] catalog = new HomePage[5];
try {
catalog[0] = new HomePage("Mark Evanier",
"http://www.newsfromme.com", "comic books");
catalog[1] = new HomePage("Todd Smith",
"http://www.sharkbitten.com", "music");
catalog[2] = new HomePage("Rogers Cadenhead",
"http://workbench.cadenhead.org", "programming");
catalog[3] = new HomePage("Juan Cole",
"http://www.juancole.com", "politics");
catalog[4] = new HomePage("Rafe Colburn",
"www.rc3.org");
}
catch (MalformedURLException e) {
System.out.println("Error: " + e.getMessage() +"\n");
// throw e;
}
try {
for (int i = 0; i < catalog.length; i++) {
System.out.println(catalog[i].owner + ": " +
catalog[i].address + " — " +
catalog[i].category);
}
}
catch (Exception e) {
System.out.println("Error: " + e.getMessage() +"\n");
throw e;
}
}
}