Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
entwurfsmuster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mki-swt2
entwurfsmuster
Commits
f31d34d1
Commit
f31d34d1
authored
3 years ago
by
Peter Hertkorn
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parent
b4be6a60
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/aliensimulator/predators/PredatorFactory.java
+27
-5
27 additions, 5 deletions
src/aliensimulator/predators/PredatorFactory.java
src/aliensimulator/predators/factory.properties
+2
-0
2 additions, 0 deletions
src/aliensimulator/predators/factory.properties
with
29 additions
and
5 deletions
src/aliensimulator/predators/PredatorFactory.java
+
27
−
5
View file @
f31d34d1
package
aliensimulator.predators
;
import
java.io.IOException
;
import
java.util.Properties
;
public
class
PredatorFactory
{
private
Properties
properties
=
new
Properties
();
public
PredatorFactory
()
{
try
{
properties
.
load
(
this
.
getClass
().
getResourceAsStream
(
"factory.properties"
));
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
public
Predator
createPredator
(
String
type
)
{
if
(
type
.
equals
(
"yautja"
))
{
return
new
Yautja
();
}
else
if
(
type
.
equals
(
"hishquten"
))
{
return
new
HishQuTen
();
}
else
return
null
;
String
handlerName
=
properties
.
getProperty
(
type
);
Class
<?>
classOfProtocolHandler
=
null
;
Predator
predator
=
null
;
try
{
classOfProtocolHandler
=
Class
.
forName
(
handlerName
);
predator
=
(
Predator
)
classOfProtocolHandler
.
newInstance
();
}
catch
(
ClassNotFoundException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
InstantiationException
e
)
{
throw
new
RuntimeException
(
e
);
}
catch
(
IllegalAccessException
e
)
{
throw
new
RuntimeException
(
e
);
}
return
predator
;
}
}
This diff is collapsed.
Click to expand it.
src/aliensimulator/predators/factory.properties
0 → 100644
+
2
−
0
View file @
f31d34d1
hishquten
=
aliensimulator.predators.HishQuTen
yautja
=
aliensimulator.predators.Yautja
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment