[go: up one dir, main page]

0% found this document useful (0 votes)
6 views8 pages

Assignment Object Model

The document outlines an individual assignment focused on object modeling and dynamic modeling, requiring the creation of UML class diagrams and implementation of design patterns in Java. It includes tasks such as reverse engineering a Java file, developing sequence and class diagrams for a sneaker notification system, and designing a lighting system with statechart and class diagrams. Additionally, it addresses the design of a web system for slow internet connections, emphasizing the importance of user experience during page loading.

Uploaded by

tarunjoseph17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views8 pages

Assignment Object Model

The document outlines an individual assignment focused on object modeling and dynamic modeling, requiring the creation of UML class diagrams and implementation of design patterns in Java. It includes tasks such as reverse engineering a Java file, developing sequence and class diagrams for a sneaker notification system, and designing a lighting system with statechart and class diagrams. Additionally, it addresses the design of a web system for slow internet connections, emphasizing the importance of user experience during page loading.

Uploaded by

tarunjoseph17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Individual Assignment: Object Modeling and Dynamic

Modeling
1. Please perform reverse engineering to compose a UML class diagram for the
provided java file, i.e., Question1.java.

2. Please implement the following design using Java, C#, or C++.


import java.util.ArrayList;
import java.util.List;

// Observer interface
interface Observer {
void update();
}

// Subject interface
interface Subject {
void subscribe(Observer o);
void unsubscribe(Observer o);
void notifyObservers();
}

// Concrete Subject
class GameBoard implements Subject {
private String state;
private List<Observer> observers;

public GameBoard() {
observers = new ArrayList<>();
state = "Initial State";
}

public void playMove(String move) {


this.state = move;
notifyObservers();
}

public String getState() {


return state;
}

@Override
public void subscribe(Observer o) {
observers.add(o);
}

@Override
public void unsubscribe(Observer o) {
observers.remove(o);
}

@Override
public void notifyObservers() {
for (Observer o : observers) {
o.update();
}
}
}

// Concrete Observer
class MatchView implements Observer {
private GameBoard gameBoard;

public MatchView(GameBoard gameBoard) {


this.gameBoard = gameBoard;
gameBoard.subscribe(this);
}

@Override
public void update() {
System.out.println("MatchView updated: Current Game State is '" +
gameBoard.getState() + "'");
}
}

// Main Program
public class GameSystem {
public static void main(String[] args) {
GameBoard board = new GameBoard();

MatchView view1 = new MatchView(board);


MatchView view2 = new MatchView(board);

board.playMove("Player 1 moves to A1");


board.playMove("Player 2 moves to B2");
}
}

3. In our lecture 11 (dynamic modeling), please combine the sequence diagrams on


pages 14 and 15 into a single sequence diagram.

4. Many customers are interested in purchasing limited-edition sneakers from an online


retail store, but these items often sell out quickly. The store wants to implement a
feature where customers can sign up to receive notifications when these sneakers are
back in stock.

Tasks:
(a) Sequence Diagram:
Create a sequence diagram that illustrates the interactions between the system's
components when a new batch of limited-edition sneakers becomes available, and
notifications are sent out to subscribed customers.
(b) Class Diagram:
Develop a class diagram that represents the structure of this scenario. Indicate the
relationships between classes, such as associations, inheritances, and
dependencies. Don’t forget multiplicity.

(c) Please ensure that your diagrams are clear, well-organized, and accurately reflect
the requirements. Include appropriate methods and attributes for each class and
interaction in your diagrams.

(d) Imagine that you are developing a lighting system. A switch has “on” and “off”
states. When the switch is turned to “on”, the light should be turned on.
Otherwise, the light should be turned off. Suppose that we have different types of
switches, such as a regular switch attaching to the wall or a remote control switch
that can remotely turn on/off the light. Please draw a statechart diagram and a
class diagram for your analysis and design.
(e) Imagine that you will develop a web system for a rural area, which only has very
slow Internet connection. As downloading images is pretty time consuming, you
want to make a place holder for the image when initializing a web page. We want
to show the text portion as soon as possible. The real images are displayed after
the text portion has been downloaded. This strategy is good because users have
something to see when they try to open a web page. Otherwise, they will lose
patience if they have to wait for a long time to see the web page. Please use the
class diagram to make the design.

You might also like