logo Use SA10RAM to get 10%* Discount.
Order Now logo

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
H. GraceSocial sciences
(5/5)

572 Answers

Hire Me
expert
Kevin BatessAccounting
(5/5)

829 Answers

Hire Me
expert
Neill BissonnetteData mining
(5/5)

861 Answers

Hire Me
expert
Penn RitchieSociology
(5/5)

603 Answers

Hire Me
Software Engineering

Suppose that a list can contain items and other lists. Therefore, the composite pattern can perfectly be used to implement such a list. For example, the list: (1 (2 3) (4 5) (6 4)) is composed of an item 1 and  three lists: (2 3), (4 5) and (6 4).

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

Question#1

Suppose that a list can contain items and other lists. Therefore, the composite pattern can perfectly be used to implement such a list. For example, the list: (1 (2 3) (4 5) (6 4)) is composed of an item 1 and  three lists: (2 3), (4 5) and (6 4).

 

In this program you will use Composite pattern and Builder pattern to implement a list structure. The following UML class diagram shows the program structure:

The program will take an input in the form: (1 (2 3) (4 5) (6 4)) and store it using a ListComponent. The program should create a ListComposite and add a child of type Item for 1. Then it will add another child of type ListComposite for (2 3), in which it will add two Items 2 and 3, and so on.

Item’s printValue() method only prints out its value. The following is a skeleton code for the main program: ListBuilder builder = new ListBuilder();

read in input list into a string and tokenize it. for each token in the input string

if (token == “(“) builder.buildOpenBracket(); else if (token == “)” builder.buildCloseBracket();

else if (token == number) builder.buildElement(number); ListComponent list = builder.getList();

list.printValue();

 

 

Question#2:

 

Proxy pattern: write the following simple program to implement 3 protection proxies. The real subject is defined as following

 

class Text {

private String content;

void setContent(String newContent) {this.content = newContent;} String getContent() {return content;}

}

 

Write proxies that can be set up at construction time to protect its real subject by allowing to read only, write only, or read/write (3 options) the content of the real subject.

Write a main program to test your proxy objects with different protection options.

Question#3:

 Write a simple class called ArrayListSubject that maintains an arraylist of objects. It provides two operations:

void append(Object obj); //append the object to the end of the arraylist void delete(Object obj); //remove the object from the arraylist

Use the observer pattern to define an observer that simply prints “an item being deleted” when the delete operation is called on ArrayListSubject.

For all these questions, test your code with some inputs. You have to submit the following to the blackboard:

 

  • Source

  • Screenshots of the output. Put all the screenshots in a single word

Related Questions

. The fundamental operations of create, read, update, and delete (CRUD) in either Python or Java

CS 340 Milestone One Guidelines and Rubric  Overview: For this assignment, you will implement the fundamental operations of create, read, update,

. Develop a program to emulate a purchase transaction at a retail store. This  program will have two classes, a LineItem class and a Transaction class

Retail Transaction Programming Project  Project Requirements:  Develop a program to emulate a purchase transaction at a retail store. This

. The following program contains five errors. Identify the errors and fix them

7COM1028   Secure Systems Programming   Referral Coursework: Secure

. Accepts the following from a user: Item Name Item Quantity Item Price Allows the user to create a file to store the sales receipt contents

Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip

. The final project will encompass developing a web service using a software stack and implementing an industry-standard interface. Regardless of whether you choose to pursue application development goals as a pure developer or as a software engineer

CS 340 Final Project Guidelines and Rubric  Overview The final project will encompass developing a web service using a software stack and impleme

Get Free Quote!

449 Experts Online