Design Patterns

Description

Create a WORD document Lab8A_LOG to record your findings as screenshots and a fewexplanations.

Don't use plagiarized sources. Get Your Custom Assignment on
Design Patterns
From as Little as $13/Page

Unformatted Attachment Preview

OOPDA Lab 08A Design Patterns
Our primary source for this lab will be
TutorialsPoint.com “Design Patterns Tutorial”
at: https://www.tutorialspoint.com/design_pattern
We will consider a bit of background on Design
Patterns, review “Factory” pattern briefly, then
focus on “Singleton”. There are examples of
the 23 different patterns. We will also note
how many “factory” classes are incorporated
into the java api – an indication of the
importance of Design Patterns in modern O-O
programming.
Note that one link within the tutorial has
“interview questions” that the authors claim
might arise in a job interview:
At right are just a few questions on the page.
Lab 8A
Create a WORD document Lab8A_LOG to record your findings as screen shots and a few
explanations.
1. Examine (no need to run this) the example project “Single Object” which I adapted from the
TutorialsPoint code.
a. Note that the code creates TWO SimpleObjects – what happens?
2. Download and open the Naïve Ticket Machine project I’ve posted — adapted from the project in
Chapter 2 of the BlueJ textbook used in IOOP.
a. In the main() method in class SingletonTesting, note added line of code to instantiate a
second TicketMachine object with, say, a different price than that in the first, and
demonstrate functionality.
b. Revise class TicketMachine to make it a Singleton.
In the line that creates the initial [single] instance, call the TicketMachine constructor
using 500 as the cost of a ticket.
c. Try to re-run your demo code that creates a new TicketMachine(…) [won’t compile!]
d. Comment out the lines in your demo to create a second TicketMachine, and revise the
original line to work with the Singleton object – and demonstrate functionality. [Hint: In
your test driver, you’ll need to get the instance, not create a new Ticket Machine.]
Deliverables:
Zip of TicketMachine project plus your WORD doc with screen shots and results
Lab 08A Design Patterns rev SP22
3/5/2022 1:17 PM
Prof W note: omitted HFJ add’l for SU19]
Lab 08A Design Patterns rev SP22
3/5/2022 1:17 PM

Purchase answer to see full
attachment