Question: Part 1 : Smithing Operations To start, you will create various methods that perform different smithing operations on words. Some methods take different numbers and
Part : Smithing Operations
To start, you will create various methods that perform different smithing operations on words.
Some methods take different numbers and types of arguments. For each method, print out
details of the operation before returning the result. The details of the operations are as
follows:
a Draw out
Drawing out is the process of stretching metal. For our "wordsmithing", this method should
take an input word and an index for it to be drawn out from. Return a copy of the input word
that has the character at the given index repeated one more time at the same location:
Example: "smithing" drawn out at index would result in "smiithing"
b Shrinking
Shrinking metal is exactly what it sounds like: making it smaller. In the case of "wordsmithing",
let's treat that as making some letters lowercase. This method should take the input word, a
starting index inclusive and an ending index exclusive and return a copy of the input word
with the specified range of characters all lowercase.
Example: "SmiTHiNg" shrunk between and exclusive would result in "SmiThing".
c Upsetting
Upsetting metal is making it thicker in one dimension. For our case, we're going to treat it as
the opposite of shrinking: making letters in a range capitalized. This method should also take
the input word, a starting index inclusive and an ending index exclusive but should return a
copy of the input word with the specified range of characters all capitalized.
Example: "SmiTHiNg" upset between and exclusive would result in "SmiTHINg".
d Punching
Punching metal is using pointy tools to put holes through a piece. For "wordsmithing", let's just
add a space instead! Your punch method should take in an input string and an index. Return a
new string with a space added before the given index, with the rest of the input shifted right.
Example: "smithing" punched at index results in "smith ing"
e Welding
Welding metal is the process of combining pieces to make a new whole. "Welding" words will
simply be concatenating them. Your weld method should take two input strings and return a
the two inputs stuck together! No need to add spaces or anything like that.
Example: "smithing" welded with "words" results in "smithingwords"
f Stamping
In metal, this is a process where a die is used to make an impression into the piece. For our
"wordsmithing", we're going to treat it as pressing a "die" into the word, leaving the letters of
the die as a stamp.
The stamp method should take in an input string representing the current workpiece, a string
representing the "die", and a starting index to stamp at
Example: Stamping "smithing" with the die "hear" at position results in "shearing".
If the position and die length is such that the stamp would go past the end of the input string,
only apply the portion of the die that impacts the characters in the input string. The input and
output strings should be the same length! Note: You do not need to use conditionals for this!
Example: Stamping "smithing" with the die s workshop" at position would only result in
"smith's" with a space at the end
Code Java language
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
