A course in the university can have a number tasks which can be assignments or tests.
Some assignments are compulsory.
When a student attempts a task, a grade and an optional feedback is given.
Explain the meaning of various class diagram notations in the following class diagram:
Consider the code below:
public interface Billable {
void bill();
}
public abstract class Item
implements Billable {
public abstract void print();
}
public class StockItem extends Item {
private Review review;
private String name;
public StockItem(
String name, Rating rating){
this.name = name;
this.review = new Review(rating);
}
@Override
public void print() {
//...
}
@Override
public void bill() {
//...
}
}
public enum Rating {
GOOD, OK, POOR
}
public class Review {
private final Rating rating;
public Review(Rating rating) {
this.rating = rating;
}
}
import java.util.List;
public class Inventory {
private List<Item> items;
public int getItemCount(){
return items.size();
}
public void generateBill(Billable b){
// ...
}
public void add(Item s) {
items.add(s);
}
}
(a) Draw a class diagram to represent the code
(b) Draw an object diagram to represent the situation where the inventory has one item with a name spanner
and a review of POOR
rating.
Explain the interactions depicted in this sequence diagram.
First, the createParser()
method of an existing ParserFactory
object is called. Then, ...
Draw a sequence diagram to represent this code snippet.
if (isFirstPage) {
new Quote().print();
}
The Quote
class:
class Quote{
String q;
Quote(){
q = generate();
}
String generate(){
// ...
}
void print(){
System.out.println(q);
}
}
new Quote().print();
as two method calls.print()
method is called.