Hw Holiday Prac..Happy Turkey Day.
Can anyone tell me if im doing doing this correctly so Far pretty please..
Problem 1: Abstract: You are going to write an abstract class called FictionChars which will embrace the following types: SpiderMan, BionicWoman, BatMan, SuperMan, WonderWoman, SixMilDollarMan, and Xmen.
Think about the common as well as distinctive characteristics of each fiction character. Define at least three variables that uniquely describe the common/distinctive characteristics and three methods that utilize them.
For example, SixMilDollarMan can be uniquely defined by three variables: name, surgical implant and the cost of capability ($6 mil) while the methods to demonstrate his characteristics are running(), jumping(), and laserFocusing() and .
* write an abstract class for these fiction characters.
* write classes for these fiction characters.
Code:
public abstract class FictChars {
protected String name,moves,weakness;
protected abstract void fight();
}
Code:
public class WonderWoman extends FictChars {
String name = "Wonder Woman";
String moves = "Wondrous Spin";
String weakness = "Street Fighters";
public void fight() {
System.out.println("4 Wondrous Spins!!!!YOUR OUT!!!");
}
public void setName(String ne){
name = ne;
}
public String toString() {
return ("Hay all my name is" + name +"My Special move is " + moves + "Weaknesses are -->" + weakness);
}
}
// tried to create a new wonderwoman object to try and call my methods . to see if they worked like
Code:
FictChars WonderWoman = new FictChars();
WonderWoman.fight();// identifier expected error