Update App.java
This commit is contained in:
parent
23162f474f
commit
e9b20f674e
@ -1,4 +1,4 @@
|
|||||||
/*
|
/*
|
||||||
* The MIT License
|
* The MIT License
|
||||||
* Copyright © 2014-2019 Ilkka Seppälä
|
* Copyright © 2014-2019 Ilkka Seppälä
|
||||||
*
|
*
|
||||||
@ -24,7 +24,7 @@
|
|||||||
package com.iluwater.component;
|
package com.iluwater.component;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
/*
|
/**
|
||||||
* Object-oriented to a certain extent can solve many problems of code reuse and data reuse,
|
* Object-oriented to a certain extent can solve many problems of code reuse and data reuse,
|
||||||
* but it also has great defects:
|
* but it also has great defects:
|
||||||
* 1.the coupling of data organization is very strong.
|
* 1.the coupling of data organization is very strong.
|
||||||
@ -36,15 +36,18 @@ import java.util.ArrayList;
|
|||||||
* A component is a part of one object. We can consider that a object contains multiple
|
* A component is a part of one object. We can consider that a object contains multiple
|
||||||
* components, in another way, multiple components can construct a object.
|
* components, in another way, multiple components can construct a object.
|
||||||
* Here is a demo using component pattern to solve a game-like problem.
|
* Here is a demo using component pattern to solve a game-like problem.
|
||||||
* A person named Bjorn who has three component: get input;judge physics state;show graphics state
|
* A person named Bjorn who has three components: input;physics;graphics
|
||||||
* These three component with a common game object can construct our protagonist:Bjorn, also can
|
* These three components with a common game object can construct our protagonist:Bjorn, also can
|
||||||
* construct other objects like dog or cat if you want to write a real game.
|
* construct other objects like dog or cat if you want to write a real game.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class App {
|
public class App {
|
||||||
|
/**
|
||||||
|
* Launcher for this demo design pattern
|
||||||
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ArrayList<Component>arrayList = new ArrayList<>();
|
ArrayList<Component> arrayList = new ArrayList<>();
|
||||||
arrayList.add(new BjornInputComponent());
|
arrayList.add(new BjornInputComponent());s
|
||||||
arrayList.add(new BjornPhysicsComponent());
|
arrayList.add(new BjornPhysicsComponent());
|
||||||
arrayList.add(new BjornGraphicsComponent());
|
arrayList.add(new BjornGraphicsComponent());
|
||||||
GameObject gameObject = new GameObject(arrayList);
|
GameObject gameObject = new GameObject(arrayList);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user