Reputation: 11
So, I am SUPER new to Java, but I am trying to make a class-specific program so that I can work on a game within Java. Here is my code:
import java.util.Scanner;
public class boxtype {
public static void main(String args[]) {
String[] melee = {"Crowbar", "Bowie Knife", "Butterfly Knife", "Knuckleduster"};
String[] pistol = {"Colt .22", "Magnum .45", "P250", "9mm Pistol"};
String[] assault = {"AK47", "M4A1", "M16", "SMG", "Mac10", "Minigun (HGE)"};
String[] shotgunsniper = {"Shotgun", "Benelli S90", "Sniper Rifle"};
String[] attachments = {"Laser Sight", "Silencer", "Scope", "Auto-target"};
Scanner scan = new Scanner(System.in);
String xy = scan.nextLine();
if (xy.equals("spyclass")) {
spyClass();
}
}
private static void spyClass(String[] assault, String[] attachments, String[] pistol) {
// TODO Auto-generated method stub
System.out.println("Spy class: ");
System.out.println("Primary weapon: " + assault[2] + " + " + attachments[2]);
System.out.println("Secondary weapon: " + pistol[1] + " + " + attachments[2]);
System.out.println("");
}
}
Basically what happens, is Eclipse returns an error saying that "spyClass is not applicable". I'm still researching how to fix, but yeah.
Upvotes: 0
Views: 59
Reputation: 408
spyClass
probably shouldn't be static
and you need to pass the arguments to it when you call it in your main
method. spyClass(assault, attachments, pistol);
Upvotes: 0
Reputation: 8928
Your spyClass
method expects a bunch of arguments, but you aren't giving it any. The line that says
spyClass();
should perhaps be something like
spyClass(assault, attachments, piston);
Upvotes: 0
Reputation: 44821
in the call to spyClass you're not passing the parameeters
It should be:
if (xy.equals("spyclass")) {
spyClass(assault, attachments, pistol);
}
Upvotes: 2