/*************************************************************
 *      Program Solving the KNAPSACK problem 		     *
 *      Author Jakub Holy                                    *
 *      For the subject PAA, LS2002                          *
 *							     *
 *	Use: Read input file.				     *
 *	Based on source from the 1st homework		     *
 *	<*stream.h> replaced by <*stream>      		     *
 *************************************************************
 */
// 	$Id: ksack_in.hh.html,v 1.1.1.1 2003/11/08 13:19:49 aja Exp $	

using namespace std;
#ifndef _KSACK_IN_HH
#define _KSACK_IN_HH
#endif
#include <iostream>
#include <fstream>
#include <assert.h>

/* A Knapsack item.*/
class Item {
public:
  int cost;
  int weight;
  Item(int weight, int cost);
  //Item(void);	// not needed anymore?
  // Output the item to a stream
  void OutputToStream(std::ostream& os)
  {
    os << "w:" << weight << " c:" << cost << "\n";
  }
friend ostream& operator<<(ostream& out, Item it){
  out<< "w:"<< it.weight << " c:"<< it.cost;
  return out;
}//
}; // Item



//********************************************************************


class KnapsackInput {
private:
  int task_id, nr_items, max_load;
  Item **items;		// array of pointers to Items
  ifstream file;	// the file with test data
public:
  KnapsackInput(const char *filename);
  ~KnapsackInput();		// close file
  bool loadNextTask(void);	// load next task from the file;if non,return false
  int getTaskID(void);
  int  getNr_items(void);
  int  getMax_load(void);
  Item **getItems(void);	// returns array of pointers to Item(s) of the task
};