[go: up one dir, main page]

Menu

[r38]: / keeping / MIT.java  Maximize  Restore  History

Download this file

106 lines (105 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
package keeping;
import database.*;
/**
@author John Younger john_younger@att.net
This class stores information about product types available for sale --
in many different versions. What I mean by that is, that when a sales item (product) is changed (replace), for example its price is modified, then both the old and new variants are kept in the database. Also,
when an item is deleted, it is not really deleted, only that a new row is appended to this table, marking it as such. In this way,
this table, MIT, might be considered to be a log-file -- because it is append-only.
<p>
When this class is created, all rows, and all variants, and all delete-ops are loaded into memory. In this way,
It is a raw load. Because of this, you must, as the external caller, reference each item by its offset (index) rather
than its name.
*/
public abstract /* Change to final */ class MIT {
/** Load the rows from file. */
public MIT() {
// not implemented.
}
/**
Create a new item. <p>
The name for the item is automatically generated.
@param cat The category into which the item is being inserted.
@return The index of the new item. This can be used to retrieve its name.
@throws IllegalArgumentException if the specified category does not exist within the MEN table.
*/
public abstract int add(String cat);
/** All the items which have not been deleted, and are in the specified category.
<p>Only the newest variants (most recent prices and so on) are returned.
@param cat The container category. See {@link keeping.MEN} for a list.
@return The indecies of the sales items in question. These can be passed asparameters to the getters of this class, MIT.
@throws IllegalArgumentException If the specified category does not exist.
*/
public abstract int[] list( String cat);
/**
Add a record to the db, marking this item as invisible.
@param item The name to include in the new record.
@throws nothing:I decided it would be too difficult to check if the item already existed or not.
*/
public abstract void delete(String item);
/**
Modify one field of an existing sales item.
@param old The index of the existing item.
@param col The X-value, zero-based, of the field to be modified.
@param value The new value for this field. It should only be inserted in a completely new record!
@return The index of the newly inserted record. This must be used as the first parameter to subsequent vary() calls.
@throws nothing -- It is too difficult to check whether this is the most recent variant or not.
*/
private int vary( int old, int col, String value) {
// Recommended to implement.
return -1;
}
/** Set a new name for this sales item.
@param item The index of this item. Can be returned by list() and so forth.
@param name The new name which the newly created record will have.
@return The new index which you must use.
*/
public abstract int setName( int item, String name);
/**
Retrieve the current name for this item.
@param item The index of this item, as returned by add();
@return Its display name.
*/
public abstract String getName( int item);
/**
Set a new price for this item, and, in so doing, create a new variant of it.
@param item The index of this item's latest variant. This is always changing.
@param price The new value the user has entered for the price.
@return The new index for this item.
*/
public abstract int setPrice( int item, float price);
/**
What is the price for this variant?
@param item The index of this variant. Does not necessarily havve to be in list();
@return The price at that time.
*/
public abstract float getPrice( int item);
/** Retrieve the llist of inventory items required in the manufacture of this product.
<p>
They are stored concatenated, in a single field, and then tokenized out.
@param item The sales item's variant's index.
@return The names of all used inventory items, corresponding to {@link keeping.SSI}
*/
public abstract String[] ingNames( int item);
/**
How much of each ingredient is being used to make this single product?
<p>
This is also stored concatenated. I would suggest with a semi-colon;
@param item The sales item variant.
@return Quantities.
*/
public abstract float[] ingQuantities( int item);
/**
Delete one ingredient.
@param item The sales item variant.
@param ing The position in the ingNames() array.
*/
public abstract void ingDelete( int item, int ing);
/**
Add neew elements to the ends of the ingNames() and ingQuantiies() arrays.
@param item The sales item variant.
@param name The name of the inventory item to add. {@link keeping.SSI} for more information.
@param quantity This can be any quantity at all.
*/
public abstract void ingAdd( int item, String name, float quantity);
}