DArtagnant / blueJ-code-highlighter

format java code in html, imitating the style of the blue-J IDE
GNU General Public License v3.0
1 stars 0 forks source link

loop for/while support #12

Closed blastegit closed 4 months ago

blastegit commented 4 months ago

Just copy paste my java code in input.txt and see the error from python :

import java.util.HashMap;

/**
 * Classe ItemList du moteur du jeu d'aventure Étrange journée : L'Ombre de la Crape.
 *
 * Permet de stocker les Items pour chacunes des pièces du jeu.
 *
 * @author 
 * @version 7.6
 */
public class ItemList
{
    private HashMap <String, Item> aInventory;

    /**
     * Constructeur des objets de la classe ItemList
     */
    public ItemList()
    {
        this.aInventory = new HashMap <String, Item>();
    }

    /**
     * @return un Item.
     * 
     * @param pItem : de type String, correspond à l'Item que l'on veut récupérer
     */
    public Item getItem(final String pItem) {
        return this.aInventory.get(pItem);
    } // getItem(.)

    /**
     * @return la HashMap de tous les Items d'une pièce.
     */
    public HashMap <String, Item> getAllItem() {
        return aInventory;
    } // getAllItem()

    /**
     * @return La liste des objets dans une pièce sous forme de String.
     */
    public String getItemString() {
        if (this.aInventory.isEmpty()){
            return "Il n'y a point d'objets intéressants à l'horizon.";
        }

        StringBuilder itemString = new StringBuilder("Objets disponibles : ");

        for (Item item : this.aInventory.values()) {
            itemString.append(item.getName());
            itemString.append(" ");
        }
        return itemString.toString();
    } // getItemString()

    /**
     * Associe un objet à une Room.
     * 
     * @param pName : de type String, correspond au nom de l'item.
     * @param pItem : de type Item, correspond à l'item à associer à une Room.
     */
    public void addItem(final String pName, final Item pItem) {
        this.aInventory.put(pName, pItem);
    } // addItem(..)

    /**
     * Supprime un objet à une Room.
     * 
     * @param pName : de type String, correspond à l'item à associer à une Room.
     */
    public void deleteItem(final String pName) {
        this.aInventory.remove(pName);
    } // deleteItem(.)

    /**
     * Vérifie si l'item est dans l'inventaire du joueur.
     * 
     * @param pItem : de type String, correspond à l'objet auprès duquel on veut vérifier s'il est
     * bien dans l'inventaire du joueur.
     * @return un boolean pour true si l'item est dans l'inventaire du joueur, false sinon.
     */
    public boolean isContaining(final String pItem) {
        return this.aInventory.containsKey(pItem);
    } // isContaining(.)
} // ItemList
blastegit commented 4 months ago

image Like this code, the indentation is not correct.

The correct one is :

public String getItemString() {
  if (this.aInventory.isEmpty()){
    return "Il n'y a point d'objets intéressants à l'horizon.";
  }
}
DArtagnant commented 4 months ago

see the error from python

here is the error : Exception("Unknown block {") please mention it next time