Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC305 Lecture 13

CSC305 Lecture 13

Individual Software Design and Development
Singleton
(202410)

Javier Gonzalez-Sanchez

October 20, 2024
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 305 Individual Software Design and Development Lecture 13. Singletons and Blackboards
  2. Singleton class MainApp { public static void Main(String []a){ Singleton

    s1 = Singleton.getInstance(); Singleton s2 = Singleton.getInstance(); // Test for same instance if (s1 == s2){ // true - Objects are the same instance } } } 10
  3. Singleton class Singleton{ private static Singleton _instance; private Singleton() {}

    public static Singleton getInstance(){ if (_instance == null){ _instance = new Singleton(); } return _instance; } } 11
  4. Blueprint 14 M a in Dr a wAre a Dr

    a wAre a Listener Repository
  5. Lab

  6. • Can we draw the last 10 dots only? •

    Can we make darker the newest dot and light-gray (white) the oldest one? • Connect all the dots with a line, but instead of following the order in which they were clicked, connect them based on the shortest distance between each dot.
  7. CSC 305 Individual Software Design and Development Javier Gonzalez-Sanchez, Ph.D.

    [email protected] Summer 2024 Copyright. These slides can only be used as study material for the class CSC305 at Cal Poly. They cannot be distributed or used for another purpose.