Sie sind auf Seite 1von 1

COMP1161 Tutorial Sheet 7

1.

2.

Create the UML representation of the following:


a. All vehicles have a chassis number, engine number and a manufacture date. A truck is a vehicle
with a tipper registration code and a max laden weight. A car is a vehicle which has a cc rating.
b. All books have an author, ISBN, and title. An author has a name, address, and affiliation and
publication license code.
c. Convert the UML from parts (a) and (b) to Java.
d. Explain any differences/similarities in the scenarios that influenced the design for each.
Given the code labeled codeA, and codeB. Correct the errors and complete implementation.

codeA

codeB

public interface CableGuide


{
int[] flow = new int[10];
public CableGuide(){
for(int i=0; i<10; i++)
flow[i] = i+1;
}
public String toString(); // print name of guide
public int changeChannel(int current); //advance
channel by 1
}

public abstract class CableGuide2


{
int[] flow = new int[10];
public CableGuide2(){
for(int i=0; i<10; i++)
flow[i] = i+1;
}
public String toString(){
String str=;
for(int x=0; x<10; x++){
str = str + \n + flow[x];
PLEASE
}
return str;
IGNORE
}
public abstract int changeChannel(int current); //advanced
channel by 1
}
public class Guide2 extends CableGuide2{

public class Guide extends CableGuide{


private String guidName;
public Guide(){
}
}

3. Given
package tutorial7;
public class Institution{
private int instCode;
protected String parish;
public Institution(int c, String p){
instCode = c;
parish = p;
}

a.

package tutorial 7;
public class School extends Institution{
int prinID; int regionNum;
public School(int code, String p){
super(code,p);
}
public String toString(){
return (instCode + "\t"+ parish + "\t" + prinID + "\t" +
regionNum);
}
}

Explain what will happen if a program creates a School called uwi and instantiates it then executes the
following line of code (make adjustments if necessary):
uwi.toString();

Das könnte Ihnen auch gefallen