Kasutaja:M2s17/proov
DE minesweeper
[muuda | muuda lähteteksti]level 1
[muuda | muuda lähteteksti]? ? ? ?
Nüüd saab valida 3 lahtrit, ning selle peale saab vastuse palju miine oli valikus. Juhul, kui kõik olid miinid või ükski polnud öeldakse 3x või 3o. Kui valin välja 3 esimest ja tähistan nad v ga, siis v6iks tulem olla selline
v v v ? ---- 2x, 1o
see tähendab, et valikus on 2 vaba koht ja 1 miin. See aga on paha, sest tuleb välistada kohtasid kus miinid olla ei saa. Seega teeme uue valiku.
? v v v ---- 2x, 1o 1x, 2o
Valikus on 2 miini ja üks vaba koht. Kuid kuna teame, et pidime 2te miini otsima, siis ? kohal miini ei ole! Nüüd näeb topelt klõps küsimärgil.
Laud peaks n2gema välja
_ ? ? ? ---- 2x, 1o 1x, 2o
Nüüd me teame, et 3 koha peal on 2 miini, ning teame 1 kohta kus ei ole miini. Proovime välja kombinatsioonid läbi, kui tühi koht on kindlasti valitud. Juhul kui tagastatakse 1x, 2o, siis teame, et teised kaks on miinid, valime välja järjekordselt asukoha mis enne valimatta jäi. Näide:
v v ? v ---- 2x, 1o 1x, 2o 1x, 2o
laud lõpuks:
_ m _ m ---- 2x, 1o 1x, 2o 1x, 2o
Näide http://www.youtube.com/watch?v=N9wTjLOulEk
Lollikindel lahend
[muuda | muuda lähteteksti]Tuleb valida kaks stabiilset üksust, ning vastavalt nendele leida kõik ülejäänud. Vali 3 üksust. Jäta endale 2 kindlat üksust ja vaheta 1 neist seni, kuni muutub tagastatv tekst. Meid huvitab siin vaid miinide arv, mis on tähistatud o-ga.
Juhul, kui
- o1 ja uus
- o2, siis uus valik on miin, vana(d) valik(ud) ei ole miin
- o3, siis vahetatav oli miin, ja kõik uues palikus pole miinid
- o2 ja uus
- o3, siis uues valikus on kõik miinid ja vana(d) vahetatav(d) pole miin(id).
- o1, siis uus valik ei ole miin, ja vahetatav(ad) oli(d) miin(id)
- o3 ja uus
- o1, siis esimese valikus polnud miine ja uus valik on miin.
- o2, siis esimese valikus olid vaid miinid ja uus valik ei ole miin.
Level 1, kordumatuid võimalusi = 6 Level 2, kordumatuid võimalusi = 126 Level 3, kordumatuid võimalusi = 12870 Ning kui oleks level 4, oleks sellel kordumatuid võimalusi = 5200300
Aura questi auhinnad
[muuda | muuda lähteteksti]Olenevalt tegelaskuju auastest ja levelist saadakse erinevaid auhindu.
Level 1
[muuda | muuda lähteteksti]IV Def 4 sõrmus STR 3,DEX 3,INT 3,HP 15,Speed 15
Level 2
[muuda | muuda lähteteksti]Level 3
[muuda | muuda lähteteksti]IV Def 8 kindad HP 10
Level 4
[muuda | muuda lähteteksti]IV Def 4 sõrmus STR 3,DEX 3,INT 3,HP 15,Speed 15
Level 5
[muuda | muuda lähteteksti]IV Limited dragon core armor W STR +7 ja DEX +4 ja INT +5
Valem
[muuda | muuda lähteteksti]Kui ja , siis
Sisu
[muuda | muuda lähteteksti]import javax.swing.*;
import javax.accessibility.*;
import java.awt.*;
import java.util.*;
public class frxg {
private static JFrame Me = new JFrame("HelloWorldSwing");
private static JLabel Label = new JLabel("Hello World");
private static JTextField TextField = new JTextField("Hello World");
private static JLabel Label2 = new JLabel("Hello World");
private static JTextField TextField2 = new JTextField("Hello World");
private static JButton Button = new JButton("Hello World");
private static JPanel panel = new JPanel();
private static void createAndShowGUI() {
//Create and set up the window.
panel.add(Label);
panel.add(TextField);
panel.add(Label2);
panel.add(TextField2);
panel.add(Button);
Me.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Me.getContentPane().add(panel);
Me.setSize(400,400);
Me.setLocation(200,200);
Me.pack();
Me.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(
new Runnable() {
public void run() {
createAndShowGUI();
}
}
);
}
}
Suvaline
[muuda | muuda lähteteksti]http://en.wikipedia.org/wiki/List_of_theorems
Lipu näide
[muuda | muuda lähteteksti]Teoreemid
[muuda | muuda lähteteksti]Alljärgnevalt on kirja pandud loetelus teoreeme
A
[muuda | muuda lähteteksti]- Abel'i teoreem ( Niels_Henrik_Abel ) (matemaatiline analüüs)
- Abel'i ja tauber'i teoreemid ( Niels_Henrik_Abel ) (Matemaatiline analüüs)
- Abel-Ruffini teoreem ( Niels_Henrik_Abel - Paolo_Ruffini ) (theory of equations, Galois theory)
- Abouabdillah's teoreem (geometry,number theory)
- Ankeny-Artin-Chowla teoreem (number theory)
- Arrow's impossibility teoreem (game theory)
- Artin-Schreier teoreem (real closed fields)
- Artin-Wedderburn teoreem (abstract algebra)
- Arzelà-Ascoli teoreem (functional analysis)
- Atiyah-Singer index teoreem (elliptic differential operators, harmonic analysis)
B
[muuda | muuda lähteteksti]- Baire category theorem (topology, metric spaces)
- Banach-Alaoglu theorem (functional analysis)
- Banach fixed point theorem (metric spaces, differential equations)
- Banach-Steinhaus theorem (functional analysis)
- Barbier's theorem (geometry)
- Bass's theorem (group theory)
- Bayes' theorem (probability)
- Beatty's theorem (diophantine approximation)
- Beck's monadicity theorem (category theory)
- Beck's theorem (incidence geometry)
- Bell's theorem (quantum theory - physics)
- Bendixson-Dulac theorem (dynamical systems)
- Bernstein's theorem (functional analysis)
- Berry-Esséen theorem (probability theory)
- Bertrand's ballot theorem (probability theory, combinatorics)
- Bertrand's postulate (prime numbers)
- Bézout's theorem (algebraic curves)
- Binomial theorem (algebra, combinatorics)
- Birkhoff's theorem (ergodic theory)
- Bohr-Mollerup theorem (gamma function)
- Bolyai-Gerwien theorem (geometry)
- Bolzano's theorem (real analysis, calculus)
- Bolzano-Weierstrass theorem (real analysis, calculus)
- Bombieri's theorem (number theory)
- Boolean prime ideal theorem (mathematical logic)
- Borel-Bott-Weil theorem (representation theory)
- Bott periodicity theorem (homotopy theory)
- Borsuk-Ulam theorem (topology)
- Brouwer fixed point theorem (topology)
- Brown's representability theorem (homotopy theory)
- Bruck-Chowla-Ryser theorem (combinatorics)
- Brun's theorem (number theory)
- Brunn-Minkowski theorem (Riemannian geometry)
- Buckingham π theorem (dimensional analysis)
C
[muuda | muuda lähteteksti]- Cantor–Bernstein–Schroeder theorem (Set theory, cardinal numbers)
- Cantor's theorem (Set theory, Cantor's diagonal argument)
- Carathéodory-Jacobi-Lie theorem (symplectic topology)
- Carathéodory's theorem (conformal mapping)
- Carathéodory's theorem (convex hull)
- Carathéodory's theorem (measure theory)
- Carmichael's theorem (Fibonacci numbers)
- Cartan's theorem (Lie group)
- Cartan's theorems A and B (several complex variables)
- Castigliano's first and second theorems (structural analysis)
- Cauchy integral theorem (Complex analysis)
- Cayley-Hamilton theorem (Linear algebra)
- Cayley's theorem (group theory)
- Central limit theorem (probability)
- Ceva's theorem (geometry)
- Chebotarev's density theorem (number theory)
- Chen's theorem (number theory)
- Chern-Gauss-Bonnet theorem (differential geometry)
- Chinese remainder theorem (number theory)
- Chowla-Mordell theorem (number theory)
- Church-Rosser theorem (lambda calculus)
- Classification of finite simple groups (group theory)
- Closed graph theorem (functional analysis)
- Cluster decomposition theorem (quantum field theory)
- Coase theorem (economics)
- Cochran's theorem (statistics)
- Compactness theorem (mathematical logic)
- Conservativity theorem (mathematical logic)
- Convolution theorem (Fourier transforms)
- Cook's theorem (computational complexity theory)
- Corona theorem (Complex analysis)
- Cox's theorem (probability foundations)
- Crystallographic restriction theorem (group theory, crystallography)
- Cut-elimination theorem (proof theory)
D
[muuda | muuda lähteteksti]- Dandelin's theorem (geometry)
- Darboux's theorem (real analysis)
- Darboux's theorem (symplectic topology)
- De Branges' theorem (complex analysis)
- De Finetti's theorem (probability)
- De Rham's theorem (differential topology)
- Deduction theorem (logic)
- Desargues' theorem (geometry)
- Descartes' theorem (geometry)
- Dilworth's theorem (combinatorics, order theory)
- Dimension theorem for vector spaces (vector spaces, linear algebra)
- Dirichlet's theorem on arithmetic progressions (number theory)
- Dirichlet's unit theorem (algebraic number theory)
- Divergence theorem (vector calculus)
- Dominated convergence theorem (Lebesgue integration)
E
[muuda | muuda lähteteksti]- Earnshaw's theorem (electrostatics)
- Ehresmann's theorem (differential topology)
- Equipartition theorem (ergodic theory)
- Erdős-Kac theorem (number theory)
- Erdős-Ko-Rado theorem (combinatorics)
- Euler's rotation theorem (geometry)
- Euler's theorem (number theory)
- Euler's theorem on homogeneous functions (multivariate calculus)
- Extreme value theorem
F
[muuda | muuda lähteteksti]- Faltings' theorem (diophantine geometry)
- Fatou-Lebesgue theorem (real analysis)
- Feit-Thompson theorem (finite groups)
- Fermat's last theorem (number theory)
- Fermat's little theorem (number theory)
- Fisher separation theorem (economics)
- Five color theorem (graph theory)
- Fixed point theorems in infinite-dimensional spaces
- Fluctuation dissipation theorem (physics)
- Fluctuation theorem
- Four color theorem (graph theory)
- Fourier inversion theorem (harmonic analysis)
- Frobenius reciprocity theorem (group representations)
- Frobenius theorem (foliations)
- Fubini's theorem (integration)
- Fuglede's theorem (functional analysis)
- Fundamental theorem of algebra (complex analysis)
- Fundamental theorem of arbitrage-free pricing (financial mathematics)
- Fundamental theorem of arithmetic (number theory)
- Fundamental theorem of calculus (calculus)
- Fundamental theorem on homomorphisms (abstract algebra)
G
[muuda | muuda lähteteksti]- Gauss theorem (vector calculus)
- Gauss's Theorema Egregium (differential geometry)
- Gauss-Bonnet theorem (differential geometry)
- Gauss-Markov theorem (statistics)
- Gauss-Wantzel theorem (geometry)
- Gelfand–Naimark theorem (functional analysis)
- Gelfond-Schneider theorem (transcendence theory)
- Gibbard-Satterthwaite theorem (voting methods)
- Girsanov's theorem (stochastic processes)
- Goddard-Thorn theorem (vertex algebras)
- Gödel's completeness theorem (mathematical logic)
- Gödel's incompleteness theorem (mathematical logic)
- Going-up and going-down theorems (commutative algebra)
- Goodstein's theorem (mathematical logic)
- Green-Tao theorem (number theory)
- Green's theorem (vector calculus)
- Gromov's compactness theorem (Riemannian geometry)
- Gromov's theorem (group theory)
- Gromov-Ruh theorem (differential geometry)
H
[muuda | muuda lähteteksti]- H-theorem (thermodynamics)
- Haag's theorem (quantum field theory)
- Haboush's theorem (algebraic groups, representation theory, invariant theory)
- Hadamard three-circle theorem (complex analysis)
- Hadwiger's theorem (geometry, measure theory)
- Hahn embedding theorem (ordered groups)
- Hairy ball theorem (algebraic topology)
- Hahn-Banach theorem (functional analysis)
- Hales-Jewett theorem (combinatorics)
- Ham sandwich theorem (topology)
- Hartogs' theorem (complex analysis)
- Hasse–Minkowski theorem
- Heine-Borel theorem (real analysis)
- Hellinger-Toeplitz theorem (functional analysis)
- Helly's theorem (convex sets)
- Herbrand-Ribet theorem (cyclotomic fields)
- Higman's embedding theorem (group theory)
- Hilbert's basis theorem (commutative algebra,invariant theory)
- Hilbert's Nullstellensatz (theorem of zeroes) (commutative algebra, algebraic geometry)
- Hilbert-Speiser theorem (cyclotomic fields)
- Hinge theorem (geometry)
- Hopf-Rinow theorem (differential geometry)
- Hurewicz theorem (algebraic topology)
- Hurwitz's automorphisms theorem (algebraic curves)
I
[muuda | muuda lähteteksti]- Intermediate value theorem (calculus)
- Implicit function theorem (vector calculus)
- Infinite monkey theorem (probability)
- Inverse function theorem (vector calculus)
- Isomorphism theorem (abstract algebra)
- Isoperimetric theorem (curves, calculus of variations)
J
[muuda | muuda lähteteksti]- Jacobson density theorem (ring theory)
- Jordan curve theorem (topology)
- Jordan-Hölder theorem (group theory)
- Jordan-Schönflies theorem (geometric topology)
- Jung's theorem (geometry)
K
[muuda | muuda lähteteksti]- Kirchhoff's theorem (graph theory)
- Kirszbraun theorem (Lipschitz continuity)
- Kleene's recursion theorem (recursion theory)
- Knaster-Tarski theorem (order theory)
- Kolmogorov-Arnold-Moser theorem (dynamical systems)
- Kolmogorov extension theorem
- König's theorem (mathematical logic)
- Kronecker's theorem (diophantine approximation)
- Kronecker-Weber theorem (number theory)
- Krull's principal ideal theorem (commutative algebra)
- Künneth theorem (algebraic topology)
L
[muuda | muuda lähteteksti]- Ladner's theorem (computational complexity theory)
- Lagrange's theorem (group theory)
- Lagrange's four-square theorem (number theory)
- Lagrange inversion theorem (mathematical analysis, combinatorics)
- Lagrange reversion theorem (mathematical analysis, combinatorics)
- Lami's theorem (statics)
- Laurent expansion theorem (complex analysis)
- Lebesgue covering dimension (dimension theory)
- Lebesgue's decomposition theorem (dimension theory)
- Lebesgue's density theorem (dimension theory)
- Lebesgue differentiation theorem (real analysis)
- Lefschetz fixed point theorem (algebraic topology)
- Lehmann-Scheffé theorem (statistics)
- Lindemann-Weierstrass theorem (transcendence theory)
- Lie-Kolchin theorem (algebraic groups, representation theory)
- Linear congruence theorem (number theory, modular arithmetic)
- Linear speedup theorem (computational complexity theory)
- Linnik's theorem (number theory)
- Liouville's theorem (complex analysis) (entire functions)
- Liouville's theorem (Hamiltonian) (Hamiltonian mechanics)
- Löb's theorem (mathematical logic)
- Löwenheim-Skolem theorem (mathematical logic)
- Lyapunov's central limit theorem (probability theory)
M
[muuda | muuda lähteteksti]- Mahler's compactness theorem (geometry of numbers)
- Mahler's theorem (p-adic analysis)
- Marcinkiewicz theorem (functional analysis)
- Marriage theorem (combinatorics)
- Master theorem (recurrence relations, asymptotic analysis)
- Maschke's theorem (group representations)
- Matiyasevich's theorem (mathematical logic)
- Max flow min cut theorem (graph theory)
- Maximum power theorem (electrical circuits)
- Maxwell's theorem (probability theory)
- Mean value theorem (calculus)
- Menger's theorem (graph theory)
- Mercer's theorem (functional analysis)
- Mertens' theorems (number theory)
- Metrization theorems (topological spaces)
- Midy's theorem (number theory)
- Mihăilescu's theorem (number theory)
- Min-max theorem (functional analysis)
- Minimax theorem
- Minkowski's theorem (geometry of numbers)
- Mitchell's embedding theorem (category theory)
- Mittag-Leffler's theorem (complex analysis)
- Modigliani-Miller theorem (finance theory)
- Mohr-Mascheroni theorem (geometry)
- Monotone convergence theorem (mathematical analysis)
- Mordell-Weil theorem (number theory)
- Morera's theorem (complex analysis)
- Morley's categoricity theorem (model theory)
- Morley's trisector theorem (geometry)
- Multinomial theorem (algebra, combinatorics)
- Myers theorem (differential geometry)
- Myhill-Nerode theorem (formal languages)
N
[muuda | muuda lähteteksti]- Nagell-Lutz theorem (elliptic curves)
- Nash embedding theorem (differential geometry)
- Nielsen-Schreier theorem (free groups)
- No cloning theorem (quantum computation)
- Noether's theorem (Lie groups, calculus of variations, differential invariants, physics)
- No-ghost theorem (vertex algebras)
- Norton's theorem (electrical networks)
- Nyquist-Shannon sampling theorem (information theory)
O
[muuda | muuda lähteteksti]P
[muuda | muuda lähteteksti]- Paley's theorem (algebra)
- Paley-Wiener theorem (Fourier transforms)
- Pappus's centroid theorem (geometry)
- Pappus's hexagon theorem (geometry)
- Parseval's theorem (Fourier analysis)
- Pascal's theorem (conics)
- Pentagonal number theorem (number theory)
- Perfect graph theorem (graph theory)
- Peter-Weyl theorem (representation theory)
- Picard theorem (complex analysis)
- Picard-Lindelöf theorem (ordinary differential equations)
- Pick's theorem (geometry)
- Pitman-Koopman-Darmois theorem (statistics)
- Plancherel theorem (Fourier analysis)
- Poincaré-Bendixson theorem (dynamical systems)
- Poincaré-Birkhoff-Witt theorem (universal enveloping algebras)
- Poincaré duality theorem (algebraic topology of manifolds)
- Poncelet-Steiner theorem (geometry)
- Post's theorem (mathematical logic)
- Prime number theorem (number theory)
- Primitive element theorem (field theory)
- Proth's theorem (number theory)
- Ptolemaios' theorem (geometry)
- Pythagorean theorem (geometry)
R
[muuda | muuda lähteteksti]- Radon's theorem (convex sets)
- Radon-Nikodym theorem (measure theory)
- Ramsey's theorem (graph theory,combinatorics)
- Rank-nullity theorem (linear algebra)
- Rao-Blackwell theorem (statistics)
- Rational root theorem (algebra,polynomials)
- Reeh-Schlieder theorem (local quantum field theory)
- Residue theorem (complex analysis)
- Rice's theorem (recursion theory, computer science)
- Riemann mapping theorem (complex analysis)
- Riemann-Roch theorem (Riemann surfaces, algebraic curves)
- Riesz representation theorem (functional analysis,Hilbert space)
- Riesz-Thorin theorem (functional analysis)
- Robertson-Seymour theorem (graph theory)
- Rolle's theorem (calculus)
- Roth's theorem (diophantine approximation)
- Rouché's theorem (complex analysis)
- Runge's theorem (complex analysis)
S
[muuda | muuda lähteteksti]- Sahlqvist correspondence theorem (modal logic)
- Sarkovskii's theorem (dynamical systems)
- Savitch's theorem (computational complexity theory)
- Schauder fixed point theorem (functional analysis)
- Schreier refinement theorem (group theory)
- Schur's lemma (representation theory)
- Schur's theorem (Ramsey theory)
- Seifert-van Kampen theorem (algebraic topology)
- Shannon's theorem (information theory)
- Simplicial approximation theorem (algebraic topology)
- Skolem-Noether theorem (simple algebras)
- Soundness theorem (mathematical logic)
- Space hierarchy theorem (computational complexity theory)
- Spectral theorem (functional analysis)
- Speedup theorem (computational complexity theory)
- Sperner's theorem (combinatorics)
- Spin-statistics theorem (physics)
- Sprague-Grundy theorem (combinatorial game theory)
- Squeeze theorem (mathematical analysis)
- Stanley's reciprocity theorem (combinatorics)
- Stark-Heegner theorem (number theory)
- Stokes' theorem (vector calculus, differential topology)
- Stolper-Samuelson theorem (economics)
- Stone's representation theorem for Boolean algebras (mathematical logic)
- Stone's theorem on one-parameter unitary groups (functional analysis)
- Stone-Tukey theorem (topology)
- Stone-von Neumann theorem (functional analysis, representation theory of the Heisenberg group, quantum mechanics)
- Stone-Weierstrass theorem (functional analysis)
- Sturm's theorem (theory of equations)
- Swan's theorem (module theory)
- Sylow theorem (group theory)
- Sylvester's theorem (number theory)
- Sylvester-Gallai theorem (plane geometry)
- Szemerédi's theorem (combinatorics)
- Szemerédi-Trotter theorem (combinatorics)
T
[muuda | muuda lähteteksti]- Takagi existence theorem (number theory)
- Taniyama-Shimura theorem (number theory)
- Tarski's indefinability theorem (mathematical logic)
- Taylor's theorem (calculus)
- Thales' theorem (geometry)
- Thevenin's theorem (electrical circuits)
- Thue's theorem
- Thue-Siegel-Roth theorem (diophantine approximation)
- Tietze extension theorem (general topology)
- Tikhonov fixed point theorem (functional analysis)
- Time hierarchy theorem (computational complexity theory)
- Tunnell's theorem (number theory)
- Tutte theorem (graph theory)
- Turán's theorem (graph theory)
- Tychonoff's theorem (general topology)
U
[muuda | muuda lähteteksti]- Uniformization theorem (complex analysis, differential geometry)
- Universal coefficient theorem (algebraic topology)
V
[muuda | muuda lähteteksti]- Van der Waerden's theorem (combinatorics)
- Vinogradov's theorem (number theory)
- Virial theorem (classical mechanics)
- Vitali theorem (measure theory)
- Vitali-Hahn-Saks theorem (measure theory)
- Von Neumann bicommutant theorem (functional analysis)
W
[muuda | muuda lähteteksti]- Weierstrass-Casorati theorem (complex analysis)
- Weierstrass preparation theorem (several complex variables,commutative algebra)
- Well-ordering theorem (mathematical logic)
- Whitehead theorem (homotopy theory)
- Whitney embedding theorem (differential manifolds)
- Wigner-Eckhart theorem (Clebsch-Gordan coefficients)
- Wilson's theorem (number theory)
- Wolstenholme's theorem (number theory)
Z
[muuda | muuda lähteteksti]Puhtad toonid
[muuda | muuda lähteteksti]
Hall[muuda | muuda lähteteksti]
|
Sinine[muuda | muuda lähteteksti]
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Roheline[muuda | muuda lähteteksti]
|
Punane[muuda | muuda lähteteksti]
|
Lisa
[muuda | muuda lähteteksti]
Kollane[muuda | muuda lähteteksti]
|
Helesinine[muuda | muuda lähteteksti]
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Värvispekter[muuda | muuda lähteteksti] |
Lilla[muuda | muuda lähteteksti]
|
See
[muuda | muuda lähteteksti]Tehase meetod disainmuster
[muuda | muuda lähteteksti]Tarkvara disainis, on tehase meetod (en: Factory Method) disainimuster objektorjenteeritud disainimuster. Nagu teised objekti loomisele suunatud mustrid, tegeleb ta probleemiga - objekti(toote) loome, täpsustamata loodava objekti klassi. Tehase meetod disainimuster kirjeldab, kuidas objekt luuakse läbi kutse meetodile, mitte otse läbi klassi konstruktori. Vahel kutsutakse tehase meetodi disainimustrit virtuaalseks konstruktoriks.
Tihti kasutatakse ja tuntakse abstraktset tehase meetod disainimustrit, st. baasklass(objekt), millest tütaklassid pärinevad, on defineeritud abstraktsena, ehk ametlikult mittelõpetatuks tunnistatud klass, mis ei võimalda endast otse elementi luua, vaid nõuab täiendamist tütarklassi näol, millena teda saab algväärtustada elemendiks.
Definitsioon
[muuda | muuda lähteteksti]Tehase meetod disainmuster on "Objekti loomeks defineeritud kasutajaliides, mis võimaldab tütarklasside näol määrata, millise klassi element luuakse. Tehase meetod võimaldab viivitada algväärtustamist tütarklassiks."
näide:
import java.util.HashMap;
import java.util.Map;
/**
* Näites on loodud abstraktne baasklass, millel on vaid kirjeldus ja staatiline ridavaliku
* tüüpi tehase meetod, mille valikuid on piiratud loendiga, mida saab valida tütarklassi
* nimega või nimele eraldatud võtmega.
*
* Klassi deklareerimise ja algväärtustamise näited:
* BaasKlass e=BaasKlass.Loo_objekt(BaasKlass.tytarklassiTyyp.tagasta(1));//korrektne
* BaasKlass e=BaasKlass.Loo_objekt(BaasKlass.tytarklassiTyyp.Toode_1);//korrektne
* BaasKlass e=new BaasKlass();//väär
*/
public abstract class BaasKlass {
private String kirjeldus = "olen baasklass";
public void tagastaKirjeldus() {
System.out.println(kirjeldus);
}
public static BaasKlass Loo_objekt(tytarklassiTyyp tyyp) {
//juhul, kui loendiga püüti tagastada argumendiks tütarklassi, mida ei eksisteeri
if (tyyp == null) {
return new Toode_1();
}
//juhul, kui tütarklassi tüüp eksisteerib
switch (tyyp) {
case Toode_2:
return new Toode_2();
case Toode_3:
return new Toode_3();
default:
return new Toode_1();
}
}
public enum tytarklassiTyyp {
//loetelu elemendid(koos võtmetega)
Toode_1(1), Toode_2(2), Toode_3(3);
//staatiline kaart, millega saab leida kindlale võtmele vastava loetelu elemendi
private static final Map<Integer, tytarklassiTyyp> elemendid = new HashMap<Integer, tytarklassiTyyp>();
//staatilise kaardi algväärtustaja
static {
for (tytarklassiTyyp x : tytarklassiTyyp.values())
elemendid.put(x.getCode(), x);
}
private int v6ti;
//loendi konstruktor
private tytarklassiTyyp(int v6ti) {
this.v6ti = v6ti;
}
public int tagastaV6ti() {
return v6ti;
}
//tagastab staatiliseest kaardist v6tmele vastava letelu elemendi
public static tytarklassiTyyp tagasta(int v6ti) {
return elemendid.get(v6ti);
}
}
}