Commit 648eb779 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="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Week2</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 Bar {
public static void main(String[] args) {
Foo f = new Foo();
Foo g = new Foo();
f. x = 42;
f. y = 9;
g. x = 16;
g. y = 33;
f.same();
f.sum();
g.same();
g.sum();
System.out.println(f.sum());
//System.out.println(f.difference());
System.out.println(g.sum());
//System.out.println(g.difference());
}
}
public class Colour {
int red;
int green;
int blue;
Colour(int r, int g, int b)
{
red = r;
green = g;
blue = b;
}
Colour(String input)
{
if(input.contentEquals("Black")) {
red = 0;
green = 0;
blue = 0;
}
if(input.contentEquals("Red")) {
red = 255;
green = 0;
blue = 0;
}
if(input.contentEquals("Green")) {
red = 0;
green = 255;
blue = 0;
}
if(input.contentEquals("Blue")) {
red = 0;
green = 0;
blue = 255;
}
if(input.contentEquals("White")) {
red = 255;
green = 255;
blue = 255;
}
}
void darker()
{
this.red *= 0.8;
this.green *= 0.8;
this.blue *= 0.8;
}
void lighter()
{
this.red *= 1.2;
this.green *= 1.2;
this.blue *= 1.2;
}
}
public class Foo {
int x;
int y;
int g;
void same() {
x = y;
}
int sum() {
return x + y;
}
int difference() {
if( x > y) {
return x - y;
}
else {
return y - x;
}
}
}
public class Main {
public static void main(String[] args) {
point a = new point ();
a.set(4.1, 5.6);
point b = new point();
b.set(9.6, 10.7);
point c = new point();
c.set(105.9, 87.1);
System.out.println(a.distance(b));
System.out.println("a is " + a.x + " " + a.y);
System.out.println("b is " + b.x + " " + b.y);
System.out.println("c is " + c.x + " " + c.y);
point d = b;
d.set(5.2, 10.9);
System.out.println("a is " + a.x + " " + a.y);
System.out.println("b is " + b.x + " " + b.y);
System.out.println("c is " + c.x + " " + c.y);
}
}
public class Main2 {
public static void main(String[] args) {
Tester t = new Tester();
}
}
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
class SetTest {
@Test
void test()
{
point a = new point();
point b = new point();
a.set(4.1, 5.6);
b.set(9.6, 10.7);
assertEquals(7.500666637039671, a.distance(b));
//fail("Not yet implemented");
}
}
public class Tester {
Tester(){
System.out.println("Constructing!");
}
}
public class Time {
int minute;
int hour;
Time(int h, int m)
{
hour = h;
minute = m;
}
void addMinutes(int m)
{
if(minute >= 60)
{
hour ++;
minute = minute + m - 60;
}
}
void addTime(Time other)
{
this.hour += other.hour;
this.minute += other.minute;
if(minute >= 60)
{
hour ++;
this.minute = this.minute + other.minute - 60;
}
}
void subtractTime(Time other)
{
this.hour -= other.hour;
this.minute-= other.minute;
if(minute >= other.minute)
{
hour --;
minute = 60;
minute -= other.minute;
}
}
String _toString()
{
String answer = Integer.toString(this.hour);
if(this.hour < 10)
{
answer = "0" + answer + ":" + Integer.toString(this.minute);
}
else
{
answer = answer + ":" + Integer.toString(this.minute);
}
return answer;
}
}
public class TimeTest {
public static void main(String[] args) {
Time t = new Time(12, 30);
System.out.println(t._toString());
}
}
public class colourDesc {
public static void main(String[] args) {
Colour red = new Colour(255, 0, 0);
}
}
public class point {
double x;
double y;
void set(double x, double y) {
//something
this.x = x;
this.y = y;
}
double distance(point other) {
//something
double answer = Math.sqrt((this.x-other.x) * (this.x-other.x) + (this.y - other.y) * (this.y-other.y));
return answer;
}
void add(point other) {
double answerA = other.x + this.x;
double answerB = other.y + this.y;
return;
}
}
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