package com.codegym.task.task04.task0401;
/*
/*
The Person class should have a public int field called age.
3. The Person class's adjustAge method should display text on the screen.
4. The Person class's adjustAge method must have only one int parameter named age,
and the method must be void.
5. The main method should call the adjustAge method only once.
6.
*/
public class Solution {
public static void main(String[] args) {
Person person = new Person();
person.age = 20;
person.adjustAge(person.age);
}
}
class Person {
public int age = 20;
public void adjustAge(int age) { // The Person class's adjustAge method should increase the Person's age by 20.
this.age = this.age + age;
System.out.println("Adjusted age: " + this.age);
}
}
Whats wrong here. It compiles
Under discussion
Comments (2)
- Popular
- New
- Old
You must be signed in to leave a comment
~mK
27 December 2019, 23:36
Thanks Boss!
I know you are helping a lot of us.
+1
Guadalupe Gagnon
23 December 2019, 22:44
While you did solve the task, you ended up removing code that should not have been. Reset the tasks and fix only the adjustAge() method.
Changes to the starting code, unless specifically told to by the requirements, is one of the more prominent ways that fail tasks. I've done it myself too, so I understand. I will copy and paste my code into a note pad for safe keeping and reset tasks to see if I had made any changes accidentally.
+2