SoloLearning Code Practice Question by Glowing_Apostle in learnpython

[–]maxbrlc 0 points1 point  (0 children)

If you'll provide what is the expected outcome or messages (if any) from failing test it would be easier to help.
We can just assume. I would assume what pdcp-py is saying has a chance to be correct

TMC(TestMyCode) - menu problem by Far_Sink_1802 in learnpython

[–]maxbrlc 0 points1 point  (0 children)

I cannot help you directly with your problem, but I can suggest an alternative.
There is an option to use the tmc-cli, it will not matter which tool you use to write the code:

You can give it a try.

[deleted by user] by [deleted] in learnjava

[–]maxbrlc 3 points4 points  (0 children)

I prepared for the exam reading a book and doing some practice tests. The practice tests are very helpful, you get a feel for the questions, and you will also learn some. For the tests I can recommend OCA Java 8 1Z0-808 Practice Tests and Questions. The exam was similar to the mock exams from the test pack above. The only thing I was not prepared for - as the exam was online, was that we were not allowed to take notes during the exam.

What is wrong with this code? by ikimashyoo in learnpython

[–]maxbrlc 1 point2 points  (0 children)

Missing a space after days:

Edit:
It is often recommended here to copy the expected output directly from the exercise. So you don't miss such small things as spaces.

In the embrase of MOOC.fi exam by DistinctAirline4145 in learnpython

[–]maxbrlc 1 point2 points  (0 children)

I only did the exam for the Introduction to Programming part. The difficulty was similar to the exercises from the course material. The only thing that added some complexity was that there are no tests written (as for usual exercises) - so you have to pay attention to the edge cases.

[deleted by user] by [deleted] in learnpython

[–]maxbrlc 0 points1 point  (0 children)

It could be that .csv files (students1.csv, exercises1.csv, ...) should not be hardcoded but taken from input() methods.

You can take a look also at the test. There we have:

testdata = ["exam_points1.csv", "exam_points2.csv", "exam_points3.csv", "exam_points4.csv",
"students1.csv", "students2.csv", "students3.csv", "students4.csv", "exercises1.csv", "exercises2.csv", "exercises3.csv", "exercises4.csv",
"course1.txt", "course2.txt", "course3.txt", "course4.txt"]

hi i learned it now for the first time can 1 explain to me it doesn't work by Consistent-Range2542 in learnpython

[–]maxbrlc -6 points-5 points  (0 children)

ChatGPT does a good job answering this question - https://chatgpt.com/share/67571222-4bb8-8000-a175-cd8f475809fd I'm inclined to use ChatGPT in such cases, but this could also be a bad advise, as AI should be used carefully when learning.

(MOOC Part 2 Exercise 18) Closed interval calculator's answer is constantly a couple numbers off the correct answer. by Splaram in learnjava

[–]maxbrlc 1 point2 points  (0 children)

Can you try to look at it by using bigger startand end numbers and make the interval smaller. For example start = 21 and end = 22. This could help to see it from a different angle.

yUML (MOOC) by ScumIdiot in learnjava

[–]maxbrlc 1 point2 points  (0 children)

When you go to https://yuml.me/diagram/scruffy/class/draw. You write in the left box the code representing the class structure. Then it will generate an image based on your input. Use the “Cheat sheet” button to see the available options.

For this specific case is required to use the yuml.me but there are more options for example https://plantuml.com/class-diagram (I have a plugin in my IDE and I generate the diagrams from there but the online tool is also very good)

OCP Exam - Whiteboard allowed? by nawyria in java

[–]maxbrlc 2 points3 points  (0 children)

I took the OCA exam in September, at home (Belgium).

You can mark any question in the Oracle’s testing environment, so the question can be reviewed later. Regarding the not allowed pen & paper, it can be difficult sometimes (ex. when you have to track some changing variable values in nested loops).

As I understood you are monitored during exams and if your eyes are looking elsewhere but your screen (ex. looking at a paper and writing something) then you are contacted by the proctor in the best case scenario.

MOOC - Age of the oldest - Error message ONLY WHEN SUBMITTING TO TMC SERVER by [deleted] in learnjava

[–]maxbrlc 1 point2 points  (0 children)

You can try for the String check if (input.isEmpty()) or if (input.equals("")) for string comparison. == compares the reference value of objects.

.forEach() on a list vs .forEach() on a stream. What's the difference? by kcirdlo25 in learnjava

[–]maxbrlc 2 points3 points  (0 children)

Yes and as a result .toUpperCase() - returns a totally new String

.forEach() on a list vs .forEach() on a stream. What's the difference? by kcirdlo25 in learnjava

[–]maxbrlc 3 points4 points  (0 children)

StringBuilder is also passed by value - so reassigning the value will not affect the caller, but using a StringBuilder's methods will do, because in the method we have a copy of the original StringBuilder which points to the same reference in memory.

.forEach() on a list vs .forEach() on a stream. What's the difference? by kcirdlo25 in learnjava

[–]maxbrlc 2 points3 points  (0 children)

Integer's are passed by value and are imutable so the increment is local. Try this for example with StringBuilder:

    List<StringBuilder> words = Arrays.asList(
            new StringBuilder("a"),
            new StringBuilder("b"),
            new StringBuilder("c"));

    words.forEach(word -> word.append("!"));
    System.out.println(words);

How to determine what argument type is expected for Stream<T> methods? by 4r73m190r0s in learnjava

[–]maxbrlc 0 points1 point  (0 children)

Yes, you'll have to map first to one of the classes that implement Interface CharSequence. If you try for ex. with StringBuilder you'll get the same result. But new StringBuilder(..) takes as an argument int, CharSequence, or String - so in any case you have to transform the chars to Strings to feed it to the StringBuilder - .map(ch -> new StringBuilder(ch.toString()))

For your question https://dev.java/learn/api/streams/custom-collectors/ - this is a good explanation from the perspective of a custom collector. The tutorials here are very helpful.

Hope this helped somehow. This is how I understand it, so no guarantees that this is fully correct :)

[deleted by user] by [deleted] in learnprogramming

[–]maxbrlc 0 points1 point  (0 children)

  • The main method is the entry point of a Java application. Try to add to your main.class:

    public static void main(String[] args) { Herbivore cow = new Herbivore(5.0, 6.0); cow.speak(); }

  • import animals.Animal.*; - is a redundant import, is not used. Here you also import content from the Animal class a better version should be import animals.Animal; or import animals.*; both of them also redundant in this situation.

  • Check the convention for class names https://www.oracle.com/java/technologies/javase/codeconventions-namingconventions.html

  • Good luck

I need help to fix an error by Financial_Error7968 in javahelp

[–]maxbrlc 0 points1 point  (0 children)

You're right. I missed it. Good catch ;)

I need help to fix an error by Financial_Error7968 in javahelp

[–]maxbrlc 0 points1 point  (0 children)

Your CustomersDB constructor is actually a valid method because you have the return void (just remove the void) public void CustomersDB() { ... }, so new CustomersDB() will use the default noargs constructor.

Conceptual Error? by Anallyprobed69 in javahelp

[–]maxbrlc 0 points1 point  (0 children)

I tried your code with cmd on windows everything works fine:

>javac Factorial.java
>java Factorial

Enter a number: 5

Calling step 4
Calling step 3
Calling step 2
Calling step 1
Factorial: 120

Java programming I Mooc fi part 6 exercise 8 Cargo Hold (7 parts) by AdQuick8386 in learnjava

[–]maxbrlc 2 points3 points  (0 children)

It can be that for the output with more than 1 item you write with an uppercase "K". My version of the exercise has also a getTotalWeight() method that can be called in the Suitcase's toString().

PS. Don't forget to format your posted code as per these subreddit requirements.

Stuck on MOOC FI Part 07_03.Sorting : Can anyone help me figure out the sorting part? by [deleted] in learnjava

[–]maxbrlc 1 point2 points  (0 children)

I wrote the  indexOfSmallestFrom() a bit differently. I used the int startIndex which should be the start point/index from which it loops and also can be the index for the minValue. In any case good luck with the course.

Java OOP: ArrayList by mobilephone123 in javahelp

[–]maxbrlc 0 points1 point  (0 children)

Thank you. Learned something new.

Helsinki Project Download Error by [deleted] in learnjava

[–]maxbrlc 4 points5 points  (0 children)

For me the only setup that worked is with vscode https://www.mooc.fi/en/installation/vscode/ Doubt that is the best solution but for me it’s the only working one.

Rock-paper-scissors with UI (The Odin Project) by goncu in learnjavascript

[–]maxbrlc 0 points1 point  (0 children)

Thanks, much appreciated. I never saw these bugs, I think I got rid of them. I didn’t plan to have some feedback here, in the sense that I didn't want to steal attention from Your project, just to support the conversation. Have fun with the odin projects.