Code Monkey home page Code Monkey logo

java-mod-2-factory-pattern-lab's Introduction

Factory Pattern Lab

Learning Goals

  • Apply the factory pattern

Instructions

Use the factory design pattern to model a camera and the different types of cameras one could have:

  • A Polaroid Camera
  • A Digital Camera
  • A Phone Camera

To fully implement the design pattern to model a camera, consider the following instructions and tips:

  • Create a Camera interface.
  • The Camera interface should have a method called takePhotograph() that returns nothing and takes no parameters.
  • Create concrete classes of PolaroidCamera, DigitalCamera, and PhoneCamera that implement the Camera interface.
  • Create a CameraFactory to instantiate each of the different types of Camera objects.

Starter Code

To help you test your code, you can use the driver class CameraDriver that has already been written out for you:

public class CameraDriver {
    public static void main(String[] args) {
        Camera polaroid = CameraFactory.getCamera("POLAROID");
        Camera digital = CameraFactory.getCamera("DIGITAL");
        Camera phone = CameraFactory.getCamera("PHONE");

        polaroid.takePhotograph();
        digital.takePhotograph();
        phone.takePhotograph();
    }
}

Expected Output

Below is the expected output from executing the CameraDriver class:

Taking a photo on my polaroid camera!
Taking a photo on my digital camera!
Taking a photo on my phone camera!

java-mod-2-factory-pattern-lab's People

Contributors

alveem avatar kcleland0818 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.