-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMagi.java
More file actions
85 lines (71 loc) · 2.79 KB
/
Copy pathMagi.java
File metadata and controls
85 lines (71 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package JavaDev;
import java.util.ArrayList;
public class Magi {
Weapon Weapon;
String name;
String Specialization;
String Aura;
byte Charge = 0;
int Age;
static ArrayList <Magi> MagisAura = new ArrayList<>(); //this is a single variable shared among all object instances since its on one class
public Magi(String name, String spec, String aura, int age){
this.name = name;
this.Specialization = spec;
this.Aura = aura;
this.Age = age;
MagisAura.add(this);
System.out.println(String.format("Magi %s has been initiated into this world.",this.name));
}
public Magi(String name, String spec, String aura, int age, String Weapon){
this.Weapon = new Weapon(Weapon, aura);
this.name = name;
this.Specialization = spec;
this.Aura = aura;
this.Age = age;
MagisAura.add(this);
System.out.println(String.format("Magi %s has been initiated into this world with the weapon '%s' of the %s.",this.name,this.Weapon.Name(),this.Weapon.Affinity));
}
public String toString(){ //implicit and explicit return when calling an object
return "(Magi Name: " + this.name + " || Magi Age: " + this.Age + " || Magi Specialization: " + this.Specialization + " || Magi Aura: " + this.Aura + ")";
}
public String Name(){
return this.name;
}
public void MagesAura(){
for (Magi mage : MagisAura){
System.out.println(mage.Aura);
}
}
public void TakeWeapon(Weapon wep){
this.Weapon = wep;
System.out.println(String.format("The weapon '%s' has been acquired by %s.",this.Weapon.Name(),this.name));
}
void BattleCry(){
System.out.println(String.format("I, %s, shall devour you with my %s",this.name,this.Specialization));
}
void PrepWep(){
if (this.Weapon != null){
System.out.println(String.format("%s has charged his weapon '%s' with his power of %s!",this.name,this.Aura,this.Weapon.Name()));
this.Charge = 1;
}
else{
System.out.println(String.format("%s currently has no weapon equipped, cannot prepare null weapon.",this.name));
}
}
public Weapon WhatWeapon(){
return this.Weapon;
}
void Attack(){
if (this.Weapon != null){
if (this.Charge == 1){
System.out.println(String.format("%s launches %s bolts with the %s!",this.name,this.Aura,this.Weapon.Name()));
}
else{
System.out.println(String.format("The %s has not been charged yet.",this.Weapon.Name()));
}
}
else{
System.out.println(String.format("%s currently has no weapon equipped, cannot attack.",this.name));
}
}
}