Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.HashMap;
- public class SymbolTable {
- private final String ALL_VALID_CHARS = "1234567890()@zxcvbnmasdfghjklqwertyuiopZXCVBNMASDFGHJKLQWERTYUIOP_;";
- private final String INITIAL_VALID_CHARS = "@MDA(";
- HashMap<String, String> map;
- // DESCRIPTION: initializes hashmap with predefined symbols
- // PRECONDITION: follows symbols/values from book/appendix
- // POSTCONDITION: all hashmap values have valid address integer
- public SymbolTable() {
- map = new HashMap<>();
- }
- // DESCRIPTION: adds new pair of symbol/address to hashmap
- // PRECONDITION: symbol/address pair not in hashmap (check contains() 1st)
- // POSTCONDITION: adds pair, returns true if added, false if illegal name
- public boolean addNewEntry(String symbol, int adress) {
- return false;
- }
- // DESCRIPTION: returns boolean of whether hashmap has symbol or not
- // PRECONDITION: table has been initialized
- // POSTCONDITION: returns boolean if arg is in table or not
- public boolean contains(String symbol) {
- return false;
- }
- // DESCRIPTION: returns address in hashmap of given symbol
- // PRECONDITION: symbol is in hashmap (check w/ contains() first)
- // POSTCONDITION: returns address associated with symbol in hashmap
- public int getAdress(String symbol) {
- return 0;
- }
- //same as part 1 but rewrite using constants
- public boolean isValidName(String symbol) {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement