(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

SET08112 Algorithms and Data Structures Coursework 2011

## Introduction

The coursework is based on a cluster of storage towers as used in a warehouse http://www.tornadostorage.com/en/storage/Tornado.html. Products are stored on trays, controlled by computer. The computer system keeps track of products. The state of the machine is stored in two files – cluster.txt and products.txt. Java programmes to read these files and create data structures are provided.

• A cluster includes several towers each identified by a number.
• A tower contains a number of movable trays – trays are numbered.
• Each tray contains ten locations labelled 1A, 1B, 2A, 2B, … 5A, 5B.
• Each location may contain several of a single product. The maximum number of products per location is typically 10 but may be some other value depending on the size of the product.
• A product has an 8 digit code, a short description, weight and number per location (ppl).

## Provided Data Structures

You may choose to use these data structures or change them as required.

### Cluster.java

This represents a cluster of towers. Essentially list of locations (each on a tray on a tower) and a list of products.

```import java.util.HashMap;
import java.util.ArrayList;
import java.io.*;

public class Cluster {
public ArrayList<Location> towers;
public HashMap<String,Product> products;
public Cluster(String productFile, String clusterFile){
try
{
products = new HashMap<String,Product>();
String s;
{
String [] f = s.split("\t");
products.put(f[0], new Product(f[0],f[1],Integer.parseInt(f[2])));
}
fh.close();

towers = new ArrayList<Location>();
{
String [] f = s.split("\t");
if (f.length==5 && f[3]!="")
else
}
fh.close();
}
catch (Exception e)
{
System.out.print("Exception: "+e);
}
}
}
```

### Location.java

This represnts a single location. A location has an address (including tower, tray and location). If a location is empty then product will be null, otherwise it holds quantity of the specified product.

```public class Location {
public String product;
public int quantity;

{
this.product = product;
this.quantity = quantity;
}
}```

### Product

Every product has id: a unique identifier, description: a user freindly name, weight: the mass in kg, ppl: products per location - the maximum number of this product that will fit into one slot.

```public class Product {
public String id;
public String description;
public int weight;

public Product(String id, String description, int weight){
this.id=id;
this.description = description;
this.weight = weight;
}
}```

The address simply encapsulates the components of a location's physical position. The posn is string such as 1A, 1B ... 5B - these are laid out on the tray as shown below. Each tray has number in a tower, each tower has a number.

```public class Address{
public int tower;
public int tray;
public String posn;
public Address(int tower, int tray, String posn){
this.tower=tower;
this.tray = tray;
this.posn = posn;
}
}```