Homework #2You must submit your work to your instructor before midnight on due date. Failure to do so will result in late penalties, see the syllabus for grading detail. Problem 1 (20 points)Draw a conceptual UML class diagram for the classes WebMailSystem, Email, User, Folder, Attachment, Mailbox, and their semantic relationships and cardinalities. These classes are part of a project that models a web-based email system. Problem 2 (20 points)Given the following UML write the corresponding Java code. Problem 3 (20 points)Given the following Java code, draw the corresponding UML class diagram. Include as much information as possible in the UML class diagram.
public interface Device {
public void setPower(double power);
}
public class Speaker {
int volume = 1;
public void setVolume(int volume) {
this.volume = volume;
}
public String toString() {
return "Volume: " + volume;
}
}
public class TV {
protected Speaker[] speaker;
public TV() {
speaker = new Speaker[2];
speaker[0] = new Speaker();
speaker[1] = new Speaker();
}
public Speaker getSpeaker(int number) {
return speaker[number-1];
}
}
public class HDTV extends TV implements Device {
private double power;
public HDTV() {
speaker[0].setVolume(8);
speaker[1].setVolume(32);
power = 128;
}
public void setPower(double power) {
this.power = power;
}
public String toString() {
String res = speaker[0] + " " + speaker[1];
return (res + " Power: " + power);
}
}
Important: Don't forget to re-read the syllabus to make sure you understand all the deliverables for assignments in this class, including this one.
$Id: hw2.html,v 1.2 2009/02/22 21:10:54 virgil Exp $ |