AutoSkill Java Multimedia Dictionary Interface Implementation
Implement a Java Interface class that parses a specific file format into an ordered dictionary and processes user commands to retrieve or manipulate multimedia records based on type and label.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/java-multimedia-dictionary-interface-implementation" ~/.claude/skills/ecnu-icalk-autoskill-java-multimedia-dictionary-interface-implementation && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/java-multimedia-dictionary-interface-implementation/SKILL.mdsource content
Java Multimedia Dictionary Interface Implementation
Implement a Java Interface class that parses a specific file format into an ordered dictionary and processes user commands to retrieve or manipulate multimedia records based on type and label.
Prompt
Role & Objective
You are a Java developer implementing an
Interface class for a multimedia ordered dictionary application. The class must read an input file, populate a BSTDictionary, and handle user commands to display or play content.
Operational Rules & Constraints
File Processing (processInputFile
)
processInputFile- Read the input file specified in
.args[0] - Read the file line by line:
- Odd lines (1, 3, 5...) are the
.label - Even lines (2, 4, 6...) represent the type and data (
).ℓ
- Odd lines (1, 3, 5...) are the
- For each pair, determine the type and data using the logic below, then insert a
into theRecord
.BSTDictionary- Convert the label to lowercase before creating the
.Key
- Convert the label to lowercase before creating the
Type Determination (determineType
)
determineTypeAnalyze the string
ℓ to determine the integer type:
- If the first character is
, return-
(Sound file).3 - If the first character is
, return+
(Music file).4 - If the first character is
, return*
(Voice file).5 - If the first character is
, return/
(Translation).2 - Else, if the string contains a
:.- If extension is
, returngif
(Animated image).7 - If extension is
, returnjpg
(Image).6 - If extension is
, returnhtml
(Webpage).8
- If extension is
- Else, return
(Definition).1
Data Extraction (extractData
)
extractData- If the line starts with
,-
,+
, or*
, the data is the substring starting from index 1./ - Otherwise, the data is the entire line.
User Commands (processUserCommands
, handleCommand
)
processUserCommandshandleCommandUse
StringReader to read commands in a loop until "exit" is entered.
Process the following commands:
: Get record with Key(label=define w
, type=1). Print data or "The word w is not in the ordered dictionary".w
: Get record with Key(label=translate w
, type=2). Print data or "There is no definition for the word w".w
: Get record with Key(label=sound w
, type=3). Play sound or print "There is no sound file for w".w
: Get record with Key(label=play w
, type=4). Play music or print "There is no music file for w".w
: Get record with Key(label=say w
, type=5). Play voice or print "There is no voice file for w".w
: Get record with Key(label=show w
, type=6). Show image or print "There is no image file for w".w
: Get record with Key(label=animate w
, type=7). Show image or print "There is no animated image file for w".w
: Get record with Key(label=browse w
, type=8). Show webpage or print "There is no webpage called w".w
: Insert Record((add w t c
,w
),t
). If exists, print "A record with the given key (w,t) is already in the ordered dictionary".c
: Remove record with Key(delete w k
,w
). If missing, print "No record in the ordered dictionary has key (w,k)".k
: Print all labels starting withlist prefix
. If none, print "No label attributes in the ordered dictionary start with prefix [prefix]".prefix
: Print attributes of the record with the smallest key (label,type,data).first
: Print attributes of the record with the largest key (label,type,data).last
: Terminate the program.exit- Invalid Command: Print "Invalid command".
Multimedia Handling
- Use
for types 3, 4, 5.SoundPlayer.play(String) - Use
for types 6, 7.PictureViewer.show(String) - Use
for type 8.ShowHTML.show(String) - Catch
and handle errors appropriately.MultimediaException
Anti-Patterns
- Do not use
for reading the input file; useStringReader
withBufferedReader
.FileReader - Do not invent new commands or error messages not specified in the requirements.
Triggers
- implement the interface class
- process input file
- handle user commands
- determine type
- java dictionary interface