当前位置:网站首页>[designmode] Prototype Pattern
[designmode] Prototype Pattern
2022-07-02 03:28:00 【weixin_ forty-three million two hundred and twenty-four thousan】
Basic introduction :
Archetypal model (Prototype Pattern ) Refer to : Using prototype instances to specify the kind of objects to create , And by copying these prototypes , Create a new object
Prototype pattern is a kind of creative design pattern , Allow one object to create another customizable object , No need to know how to create details
How it works : By passing a prototype object to the object to launch the creation , The object to be created is implemented by requesting prototype objects to copy themselves , namely object .clone()
1. The problem of sheep cloning
Now there is a sheep tom, The name is : tom, Age is :1, The color is : white , Please write a program to create and tom sheep The attributes are exactly the same 10
A sheep .
2. The traditional way to solve the problem of sheep cloning
Class diagram :

Code :
package com.mumu.prototype;
public class 边栏推荐
- MySQL connection query and subquery
- 终日乾乾,夕惕若厉
- Gradle notes
- FFMpeg AVFrame 的概念.
- Comment élaborer une stratégie nuageuse à l'ère des nuages mixtes
- MySQL之账号管理
- Unity脚本的基础语法(7)-成员变量和实例化
- Kotlin 基础学习13
- Docker installs canal and MySQL for simple testing and implementation of redis and MySQL cache consistency
- Retrofit's callback hell is really vulnerable in kotlin synergy mode
猜你喜欢

"Analysis of 43 cases of MATLAB neural network": Chapter 41 implementation of customized neural network -- personalized modeling and Simulation of neural network

Verilog state machine

Verilog parallel block implementation

PY3, PIP appears when installing the library, warning: ignoring invalid distribution -ip

Form custom verification rules

ThreadLocal详解
![[C Advanced] brother Peng takes you to play with strings and memory functions](/img/95/ab1bb0b3fa0b99e32233a5ca5d42a4.jpg)
[C Advanced] brother Peng takes you to play with strings and memory functions

Pointer array & array pointer

Failed to upgrade schema, error: “file does not exist

Pycharm2021 delete the package warehouse list you added
随机推荐
一天上手Aurora 8B/10B IP核(5)----从Framing接口的官方例程学起
verilog 并行块实现
Retrofit's callback hell is really vulnerable in kotlin synergy mode
Work hard all day long and be alert at sunset
Unity脚本的基础语法(7)-成员变量和实例化
Kotlin basic learning 16
Exchange rate query interface
[untitled] basic operation of raspberry pie (2)
Load different fonts in QML
C # joint Halcon's experience of breaking away from Halcon environment and various error reporting solutions
Analyse de 43 cas de réseaux neuronaux MATLAB: Chapitre 42 opérations parallèles et réseaux neuronaux - - opérations parallèles de réseaux neuronaux basées sur CPU / GPU
Failed to upgrade schema, error: “file does not exist
C#聯合halcon脫離halcon環境以及各種報錯解决經曆
Grpc快速实践
Global and Chinese markets for hand hygiene monitoring systems 2022-2028: Research Report on technology, participants, trends, market size and share
知物由学 | 自监督学习助力内容风控效果提升
In the era of programmers' introspection, five-year-old programmers are afraid to go out for interviews
Knowing things by learning | self supervised learning helps improve the effect of content risk control
ORA-01547、ORA-01194、ORA-01110
C#联合halcon脱离halcon环境以及各种报错解决经历