#As a novice i m facing this error

1 messages · Page 1 of 1 (latest)

eternal tangle
#

public class magic {

    public static void main(String[] args) {
        int x = 1;

        // Create mage objects
        mage m1 = new mage();  // Object 1
        m1.no = 1;
        m1.type = "Warlock";

        mage m2 = new mage(); // Object 2
        m2.no = 2;
        m2.type = "Necromancer";

        mage m3 = new mage(); // Object 3
        m3.no = 3;
        m3.type = "Alchemist";

        // Pass mage objects to getType
        getType(x, m1, m2, m3);
    }

    public static void getType(int x, mage m1, mage m2, mage m3) {
        // Check which mage matches the input number
        if (m1.no == x) {
            m1.mage_type();
        } else if (m2.no == x) {
            m2.mage_type();
        } else if (m3.no == x) {
            m3.mage_type();
        } else {
            System.out.println("Not correct value");
        }
    }
} ```

error I m facing
celest bayBOT
#

<@&987246399047479336> please have a look, thanks.

lament helm
#

As the error states, it expects 1 argument (an int) and you're passing in none.

#

Hence the difference in argument list error.

graceful sapphire
#

it would be pretty helpful if you share your mage class, especially the mage_type() method

eternal tangle
#

ooh

#

i fixed it

#

eventually

lament helm
#

Also I recommend following this course based upon your code:

celest bayBOT
#

For learning Java, we recommend MOOC.

It is a completely free introductory Java course created by the University of Helsinki, it is a great way to learn Java from the ground up.

Visit MOOC here:
https://java-programming.mooc.fi
(the course is available in both English and Finnish)

  • The MOOC teaches a broad introduction to programming in Java in two parts - one at beginner, and another at intermediate level.
    The end of the course is marked by creating your own Asteroids game clone!
  • The MOOC allows using features up to Java 11 - you can install Temurin OpenJDK 11 from the Adoptium project.
  • To submit exercises for evaluation, you need to configure an Editor/IDE (Integrated Development Environment) with the TMC Plugin.

The course instructions will suggest to use TMCBeans/NetBeans or VS Code for the course, but you can also use IntelliJ, which we generally recommend.

  • TMCBeans/NetBeans is the easiest to configure - but has the most dated user experience
  • VS Code is very popular as an editor, but it is quite new for Java Development. Some extra configuration is needed.
  • IntelliJ arguably has the best user experience and is most widely used Java IDE by professionals.
    IntelliJ requires installing a version no newer than 2023.1 - because the IntelliJ TMC Plugin doesn't work with newer installs.
    The IntelliJ Community version is completely free and all you need to install the TMC plugin.

To use IntelliJ with the MOOC, simply install the TMC plugin by opening IntelliJ -> File -> Settings -> Plugins and searching for TMC. You will then be able to use IntelliJ to complete MOOC.

About the course - Java Programming

eternal tangle
#

thnx again