Skip to content
Snippets Groups Projects
Commit 0126badf authored by joeappleton18's avatar joeappleton18
Browse files

inital commit

parents
No related branches found
No related tags found
No related merge requests found
.classpath
target/
\ No newline at end of file
.project 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>l_1</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1706524448930</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
<mxfile host="www.draw.io" modified="2020-02-11T17:01:16.386Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" etag="DYxqz526tkpydjfz14Z1" version="12.6.7" type="device"><diagram id="JwbvAOp0JcOYIXcvrSYU" name="Page-1">7Vprb+o4EP01SHdXosob7scCfazUrqpS3d3uN0PcxKoTcx1T4P76HSc2eTihlIW20laqRDyZDPE5Z8Zjl547TtZXHC3iWxZi2nOscN1zJz3HcSxvCB/SsiksthVYhSXiJFS20jAlv7B2VNYlCXFWcxSMUUEWdeOcpSmei5oNcc5WdbcnRuvfukARNgzTOaKm9S8SilhZ7eB7eeMakyhWXz10BsWNBGlnNZMsRiFbVUzuRc8dc8ZEcZWsx5hK9DQuxXOXHXe3L8ZxKvZ54NlhG2d65f/58Iif5yQYDfHPvu0XYV4QXaoZ95yAQsCR/kSzTHAE0DpBpOzq07pnLFGTExuNWLYiCUUpjEZPLBVTdceWoSiJU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m+ZWSC5YvSo8kxeT9bVwUYNOtktUNujYn4SGXjfG+z5B8rgVT2dWgZt/yb7MBl8EnaN3Dy0IL9jkl9fMfdH8kf/4f760Xd+Yvf28p++uZbau9hli3wvVmW3XE8dfdKovUOCEpaGDzFJG4eQtqcNldVXcqtPQmG3FrOIpYhelNbXdpgzddo4atVKi546u55+nRX3OCXBauxZBtZhogn8VwJ1iAZ4QZuKm9qodS9lHS/cWap2+8NF8QZ7KhiG5U8ECvfylxbuxb8=</diagram></mxfile>
\ No newline at end of file
# Lab 1
This is the source code for COM1028 lab_1
## Getting Started
pom.xml 0 → 100644
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.1028</groupId>
<artifactId>l_1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<description>Lab 1 Code</description>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
\ No newline at end of file
package l_1;
/**
* This is a skeleton class which provides an implementation of a room
*
* Notice that this class is just repeating the same code as the other classes
* which
* implement Room, so consider changing Room to an abstract class. How would you
* reflect
* this on the class diagram?
*
* @author css2ht
*
*/
public class Bedroom implements Room {
private double area = 0.0;
public Bedroom(double area) {
this.area = area;
}
@Override
public double getArea() {
return this.area;
}
}
\ No newline at end of file
package l_1;
public class DiningRoom implements Room {
private double area = 0.0;
public DiningRoom(double area) {
this.area = area;
}
@Override
public double getArea() {
return this.area;
}
}
package l_1;
import java.util.ArrayList;
import java.util.List;
public class House {
private List<Room> rooms = new ArrayList<Room>();
public House() {
}
/**
* simple method to add a room to a house
*
* @param room
*/
public void addRoom(Room room) {
this.rooms.add(room);
}
public int howManyRooms() {
return this.rooms.size();
}
/**
* Complete a foreach loop to work out the total area of the rooms in the house
*
* @return
*/
public double getTotalArea() {
double total = 0.0;
// missing the loop....
return total;
}
}
package l_1;
public class HouseBuilder {
public static void main(String[] args) {
System.out.println("hello world");
}
}
package l_1;
/**
* This is a skeleton class which provides an implementation of a room
*
* Notice that this class is just repeating the same code as the other classes
* which
* implement Room, so consider changing Room to an abstract class. How would you
* reflect
* this on the class diagram?
*
* @author css2ht
*
*/
public class Lounge implements Room {
private double area = 0.0;
public Lounge(double area) {
this.area = area;
}
@Override
public double getArea() {
return this.area;
}
}
\ No newline at end of file
package l_1;
/**
* This is a skeleton class which provides an interface
*
* @author css2ht and Joe Appleton
*
*/
public interface Room {
/**
* Gets the area of a room.
* @param void.
* @return double.
*/
public double getArea();
}
package l_1;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* This is a simple test class which provides until tests for the House class
* from exercise 1
*
* @author css2ht
*
*/
class HouseTest {
private House house;
@BeforeEach
public void setUp() {
house = new House();
/** Set up a particular kind of house */
Lounge lounge1 = new Lounge(10.0);
Lounge lounge2 = new Lounge(15.0);
DiningRoom dining1 = new DiningRoom(16.0);
house.addRoom(lounge1);
house.addRoom(lounge2);
house.addRoom(dining1);
}
/**
* 3. The house shall be able to display how many rooms it has.
*/
@Test
void testRequirement3() {
assertEquals(house.howManyRooms(), 3);
}
/**
* 4. The house shall be able to display the total area of all its rooms.
*/;
@Test
void testRequirement4() {
assertEquals(house.getTotalArea(), 41.0);
}
@AfterEach
public void tearDown() throws Exception {
house = null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment