Advertisement
snakemelon

java

Mar 13th, 2022
41
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Item {
  2. String name;//物品名称
  3. int price; //价格
  4. public void setName(String name) {
  5. this.name = name;
  6. }
  7. public String getName() {
  8. return name;
  9. }
  10. public void setPrice(int price) {
  11. this.price = price;
  12. }
  13. public int getPrice() {
  14. return price;
  15. }
  16. }
  17.  
  18. public class Weapon extends Item{
  19. int damage; //攻击力
  20. public static void main(String[] args){
  21. Weapon Infinity_Sword;
  22. Infinity_Sword = new Weapon();
  23. Infinity_Sword.damage = 65;
  24. Infinity_Sword.name = "无尽之刃";
  25. Infinity_Sword.price = 3600;
  26. System.out.println(Infinity_Sword.name);
  27. }
  28. }
  29.  
  30. Weapon garen_world = new Weapon();
  31. System.out.println(garen_world.name);
  32.  
Advertisement
RAW Paste Data Copied
Advertisement