Commit 6eabb116 authored by quinn.haigh's avatar quinn.haigh

first commit

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Character</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
public class Character1
{
public String firstName;
public String surname;
};
public class Character2
{
private String firstName;
private String surname;
public void setName(String n)
{
String[] names = n.split(" ");
firstName = names[0];
surname = names[names.length-1];
}
public String getName()
{
return firstName + " " + surname;
}
};
import java.util.ArrayList;
public class CharacterMain1
{
public static void main(String[] args) {
ArrayList<Character1> characters = new ArrayList<Character1>();
Character1 c = new Character1();
c.firstName = "Zaphod ";
c.surname = "Beeblebrox";
characters.add(c);
c = new Character1();
c.firstName = "Ford ";
c.surname = "Prefect";
characters.add(c);
c = new Character1();
c.firstName = "Arthur ";
c.surname = "Dent";
characters.add(c);
c = new Character1();
c.firstName = "Deep ";
c.surname = "Thought";
characters.add(c);
c = new Character1();
c.firstName = "Tricia ";
c.surname = "McMillan";
characters.add(c);
for (Character1 x: characters) {
System.out.println(x.firstName + x.surname);
}
}
}
import java.util.ArrayList;
public class CharacterMain2
{
public static void main(String[] args) {
ArrayList<Character2> characters = new ArrayList<Character2>();
Character2 c = new Character2();
c.setName("Zaphod Beeblebrox");
characters.add(c);
c = new Character2();
c.setName("Ford Prefect");
characters.add(c);
c = new Character2();
c.setName("Arthur Phillip Dent");
characters.add(c);
c = new Character2();
c.setName("Deep Thought");
characters.add(c);
c = new Character2();
c.setName("Tricia McMillan");
characters.add(c);
for (Character2 x: characters) {
System.out.println(x.getName());
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment