Package info.walnutstreet.vs.ps03v2.client.cache

Examples of info.walnutstreet.vs.ps03v2.client.cache.GoodList


  public AppClient() throws SystemConsoleNotFoundException {
    this.console = System.console();
    if (this.console == null)
      throw new SystemConsoleNotFoundException();
    this.controller = ConnectionController.getInstance();
    this.cart = new MyGoodCart();
  }
View Full Code Here


   * @throws IOException
   * @throws NotBoundException
   */
  private void handleRequestForGoodList() throws IOException, NotBoundException {
    Collection<Good> collection = ServerGoodList.getInstance().getGoodList();
    Answer answer = new Answer();
    answer.setData(collection);
   
    StatusMessage message = new StatusMessage();
    message.setStatus(true);
    outputStream.writeObject(message);
    outputStream.writeObject(answer);
View Full Code Here

   */
  @Override
  public void run() {
    try {
      while (this.socket.isConnected()) {
        CommandData data = (CommandData)inputStream.readObject();
        System.out.println("Client send command: " +  data.getCommand());
       
        switch (data.getCommand()) {
          case CLIENT_SENDS_REQUEST_BUY_MY_CART:
            this.handleRequestBuyMyCart();
            break;
          case CLIENT_SENDS_REQUEST_EDIT_RESERVE_GOOD: // OK
            this.handleEditReservationGood(data.getId(), data.getNumber());
            break;
          case CLIENT_SENDS_REQUEST_DELETE_RESERVE_GOOD: // OK
            this.handleRequestDeleteReservatedGood(data.getId());
            break;
          case CLIENT_SENDS_REQUEST_FOR_GOOD_LIST: // OK
            this.handleRequestForGoodList();
            break;
          case CLIENT_SENDS_REQUEST_RESERVE_GOOD: // OK
            this.handleRequestReserveGood(data.getId(), data.getNumber());
            break;
          default:
            break;
        }
      }
View Full Code Here

        String name = result.getString(2);
        String description = result.getString(3);
        int available = result.getInt(4);
        double price = result.getDouble(5);
       
        Good good = new Good();
        good.setId(id);
        good.setName(name);
        good.setDescription(description);
        good.setAvailable(available);
        good.setPrice(price);
       
        ids.add(good);
      }
    } catch (SQLException e) {
      return null;
View Full Code Here

   * Handle the request if the user want's to buy all the goods in his cart.
   *
   * @throws IOException
   */
  private void handleRequestBuyMyCart() throws IOException {
    StatusMessage message = new StatusMessage();
    message.setStatus(this.cart.buy());
   
    this.outputStream.writeObject(message);
  }
View Full Code Here

   *
   * @param id The id of the good to delete.
   * @throws IOException
   */
  private void handleRequestDeleteReservatedGood(Integer id) throws IOException {
    StatusMessage message = new StatusMessage();
    message.setStatus(this.cart.removeReservation(id));
   
    outputStream.writeObject(message);
  }
View Full Code Here

   * @param id The number of the good.
   * @param number The new number of reservations.
   * @throws IOException
   */
  private void handleEditReservationGood(Integer id, Integer number) throws IOException {
    StatusMessage message = new StatusMessage();
    message.setStatus(this.cart.editReservation(id, number));
   
    outputStream.writeObject(message);
  }
View Full Code Here

   * @param id The good's id.
   * @param number The number of goods.
   * @throws IOException
   */
  private void handleRequestReserveGood(int id, int number) throws IOException {
    StatusMessage message = new StatusMessage();
    message.setStatus(this.cart.reserveGood(id, number));
   
    outputStream.writeObject(message);
  }
View Full Code Here

  private void handleRequestForGoodList() throws IOException, NotBoundException {
    Collection<Good> collection = ServerGoodList.getInstance().getGoodList();
    Answer answer = new Answer();
    answer.setData(collection);
   
    StatusMessage message = new StatusMessage();
    message.setStatus(true);
    outputStream.writeObject(message);
    outputStream.writeObject(answer);
  }
View Full Code Here

   * @param socket Socket to communicate with the client.
   * @throws IOException
   * @throws NotBoundException
   */
  public ClientHandler(Socket socket) throws IOException, NotBoundException {
    this.cart = new ServerSideClientCart();
    this.socket = socket;
    this.outputStream = new ObjectOutputStream(socket.getOutputStream());
    this.inputStream = new ObjectInputStream(socket.getInputStream());
  }
View Full Code Here

TOP

Related Classes of info.walnutstreet.vs.ps03v2.client.cache.GoodList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.