Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Pulled out a class to represent command-line arguments. And we're ove…

…r the ten class limit per package--time to do some organizing.
  • Loading branch information...
commit a143781fa4650d3592d61b3958183504bb0b1496 1 parent 450cb87
@moss authored
View
15 src/net/m14m/katas/messaging/Arguments.java
@@ -0,0 +1,15 @@
+package net.m14m.katas.messaging;
+
+public class Arguments {
+ private String[] arguments;
+
+ public Arguments(String... arguments) {
+ this.arguments = arguments;
+ }
+
+ public Message createMessage() {
+ Address address = new Address(arguments[0]);
+ Body body = new Body(arguments[1]);
+ return new Message(new AddressList(address), body);
+ }
+}
View
7 src/net/m14m/katas/messaging/Main.java
@@ -14,11 +14,10 @@ public static void setConsole(Writer console) {
errorReporter = new ErrorReporter(console);
}
- public static void main(String... args) {
+ public static void main(String... stringArguments) {
+ Arguments arguments = new Arguments(stringArguments);
ErrorBroadcaster errorBroadcaster = new ErrorBroadcaster(errorReporter, network);
- Address address = new Address(args[0]);
- Body body = new Body(args[1]);
- Message message = new Message(new AddressList(address), body);
+ Message message = arguments.createMessage();
message.validate(errorBroadcaster);
network.sendMail(message);
}
Please sign in to comment.
Something went wrong with that request. Please try again.