예제 #1
0
 public void processItem() {
   createItem();
   if (item != null) {
     text_info.setText(item.toString());
     btn_confirm.setDisable(false);
   }
 }
예제 #2
0
  private String buildInvoice() {
    double taxRate = 6;
    String message;

    this.grandTotal = ((taxRate / 100) * this.subtotal) + this.subtotal;

    DateFormat dateFormat = new SimpleDateFormat("dd/MM/YY HH:mm:ss z");
    this.transDate = new Date();

    message = "Date: " + dateFormat.format(this.transDate) + "\n\n";
    message += "Number of line items: " + this.totalItems + "\n\n";
    message += "Item# / ID / Title / Price / Qty / Disc % / Subtotal:\n\n";
    int counter = 0;
    for (Item i : order.getOrder()) {
      counter++;
      message += counter + ". " + i.toString() + "\n";
    }
    message += "\n";
    message += "Order subtotal: " + formatter.format(this.subtotal) + "\n\n";
    message += "Tax rate: " + taxRate + "%\n\n";
    message += "Tax amount: " + formatter.format(((taxRate / 100) * this.subtotal)) + "\n\n";
    message += "Order total: " + formatter.format(this.grandTotal) + "\n\n";
    message += "Thanks for shopping at Funky Town Books\n\n";

    return message;
  }
예제 #3
0
 @Test
 public void should_toString() {
   org.assertj.core.api.Assertions.assertThat(ITEM.toString())
       .isEqualTo(
           "Item{id=1, title='Fake Item', url='http://fakeItem.com', pubdate="
               + NOW
               + ", description='Fake item description', mimeType='video/mp4', length=123456, status='NOT_DOWNLOADED', progression=0, downloaddate=null, podcast=Podcast{id=1, title='Fake Podcast', url='null', signature='null', type='Youtube', lastUpdate=null}, numberOfTry=0}");
 }
예제 #4
0
 public static int getItemID(Item item) {
   for (int i = 0; i < allTheItems.length; ++i) {
     if (item.toString().equalsIgnoreCase(allTheItems[i].toString())) {
       return i;
     }
   }
   throw new UncheckedDemigodsException(
       "Item " + item + " does not have a spot in the ID list. Check the spelling.");
 }
 private String toStr() {
   StringBuilder sb = new StringBuilder();
   for (Item i : a) {
     if (i != null) {
       sb.append(i.toString());
       sb.append(" ");
     }
   }
   return sb.toString();
 }
예제 #6
0
 /**
  * Method return the output of the ticket calculating the taxes
  *
  * @return a string representing the ticket to print
  */
 public String print() {
   StringBuffer sb = new StringBuffer();
   for (Item item : itemList) {
     sb.append(item.toString());
     calculateTotal(item.getPrice(), item.getTax().getTaxValue());
   }
   sb.append("Sales Taxes: ").append(this.totalTax.toString()).append("\n");
   sb.append("Total: ").append(this.total.toString()).append("\n");
   return sb.toString();
 }
예제 #7
0
 public static Item getItemFromString(String s) throws DemigodsException {
   Item item = null;
   for (Item i : allTheItems) {
     if (i.toString().equalsIgnoreCase(s)) {
       item = i;
       break;
     }
   }
   if (item == null) throw new DemigodsException("Item not found.");
   return item;
 }
예제 #8
0
  public void viewOrder() {
    String currentOrder = "";
    int counter = 0;
    for (Item i : order.getOrder()) {
      counter++;
      currentOrder += counter + ". " + i.toString() + "\n";
    }
    Alert alert = new Alert(Alert.AlertType.INFORMATION);
    alert.setTitle("Current Order");
    alert.setHeaderText("Your current order is as follows:");
    alert.setContentText(currentOrder);
    alert.getDialogPane().setStyle(" -fx-max-width:500px; -fx-pref-width: 500px;");

    alert.showAndWait();
  }
예제 #9
0
  /**
   * Returns the room description and a list with the ids of the items and their description that
   * belongs to this room. <> <>
   *
   * @return The room description
   */
  public String getDescription() {
    String aux = "";
    String infoItems = "";
    Iterator<Item> it = this.items.iterator();
    if (it.hasNext()) {
      aux = this.description + Msg.room_items;
      ;
      while (it.hasNext()) {
        Item auxItem = it.next();
        infoItems = infoItems + auxItem.toString() + "\n";
      }
    } else aux = this.description + Msg.room_empty;

    return aux + infoItems;
  }
예제 #10
0
 /* (non-Javadoc)
  * @see de.enough.polish.ui.TextField#defocus(de.enough.polish.ui.Style)
  */
 protected void defocus(Style origStyle) {
   super.defocus(origStyle);
   if (!this.isAllowFreeTextEntry
       && this.numberOfMatches > 0
       && this.choicesContainer.size() > 0) {
     Item item = this.choicesContainer.get(0);
     if (item instanceof StringItem) {
       setString(((StringItem) item).getText());
     } else {
       setString(item.toString());
     }
   }
   this.numberOfMatches = 0;
   this.choicesContainer.clear();
   openChoices(false);
 }
예제 #11
0
 // Prepares and returns the String representation of ItemSet object
 // which is all items concatenated and separated with separator character.
 @Override
 public String toString() {
   // TODO Before appending items to the string builder, first a new list
   // must be created and sorted. The items' values should be appended.
   // after sorting.
   // m_lstItemList.sort() must not be called to perform sort operation
   // because this would change the state of the object and may
   // cause problems (even tough not very likely, but working on a temporary list
   // seems the best way to go.)
   // toString() is not used for computational purposes, so this can left as is for
   // the time being.
   StringBuilder sb = new StringBuilder();
   for (Item item : m_lstItemList) {
     sb.append(item.toString());
     sb.append(SystemDefinitions.SEPARATOR);
   }
   return sb.toString().substring(0, sb.toString().length() - 1);
 }
예제 #12
0
파일: Test9.java 프로젝트: w20090905/nebula
 static void printStack(Stack<Item> sa) {
   System.out.println("=========Stack<Item> sa========");
   for (Item i : sa) {
     System.out.println("  >>   " + i.toString() + "'" + i.status);
   }
 }
예제 #13
0
  /* (non-Javadoc)
   * @see de.enough.polish.ui.TextField#handleKeyReleased(int, int)
   */
  protected boolean handleKeyReleased(int keyCode, int gameAction) {
    // #debug
    // # System.out.println("handleKeyReleased( keyCode=" + keyCode + ", gameAction=" + gameAction +
    //  ", isInChoice=" + this.isInChoice + ", isOpen=" + this.isOpen + ", matches=" +
    // this.numberOfMatches +" )");
    boolean isFireGameAction = getScreen().isGameActionFire(keyCode, gameAction);
    if (this.isInChoice) {
      if (this.choicesContainer.handleKeyReleased(keyCode, gameAction)) {
        // #debug
        // # System.out.println("handleKeyReleased handled by choices container");
        if (this.choicesContainer.internalX != Item.NO_POSITION_SET) {
          this.internalX = this.choicesContainer.relativeX + this.choicesContainer.internalX;
          this.internalY = this.choicesContainer.relativeY + this.choicesContainer.internalY;
        }
        return true;
      }
      // System.out.println("focusing textfield again, isFocused=" + this.isFocused);

      if (isFireGameAction) {
        enterChoices(false);
        // option has been selected!
        Item item = this.choicesContainer.getFocusedItem();
        item.notifyItemPressedEnd();
        String choiceText;
        if (item instanceof ChoiceItem) {
          choiceText = ((ChoiceItem) item).getText();
        } else if (item != null) {
          choiceText = item.toString();
        } else {
          return false;
        }
        if (this.isAppendMode) {
          String currentText = getString();
          if ((currentText != null)) {
            if (this.appendDelimiterIndex != -1
                && this.appendDelimiterIndex < currentText.length()) {
              currentText = currentText.substring(0, this.appendDelimiterIndex);
            }
            if (choiceText.startsWith(currentText)) {
              if (this.appendChoiceDelimiter != null) {
                choiceText += this.appendChoiceDelimiter;
              }
            } else {
              if (this.appendChoiceDelimiter == null) {
                choiceText = currentText + choiceText;
              } else {
                if (this.choiceTriggerEnabled) {
                  choiceText = currentText + choiceText + this.appendChoiceDelimiter;
                } else if (currentText.endsWith(this.appendChoiceDelimiter)) {
                  choiceText = currentText + choiceText + this.appendChoiceDelimiter;
                } else {
                  choiceText =
                      currentText
                          + this.appendChoiceDelimiter
                          + choiceText
                          + this.appendChoiceDelimiter;
                }
              }
            }
          } else if (this.appendChoiceDelimiter != null) {
            choiceText += this.appendChoiceDelimiter;
          }
          this.appendDelimiterIndex = choiceText.length();
        }
        if (!this.isAllowFreeTextEntry) {
          this.lastMatchingText = choiceText;
        }
        // #if polish.usePolishGui
        setString(choiceText);
        setCaretPosition(choiceText.length());
        // #endif
        this.numberOfMatches = 0;
        openChoices(false);
        super.notifyStateChanged();
      }
      return true;
    } else if (isFireGameAction) {
      notifyItemPressedEnd();
      openChoices(!this.isOpen);
      return true;
    }
    return super.handleKeyReleased(keyCode, gameAction);
  }
예제 #14
0
 public Rect4f getItemRect(Item item) {
   Rect4f rect = itemRects.get(item);
   if (rect != null) return rect;
   else throw new NoSuchElementException(item.toString());
 }