Koen Ursem

+ Follow
since Nov 15, 2018
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Koen Ursem

I think you have the idea frameworks are only big bulky frames that do allot of things and force you to go one way. But if you look at the wiki list of frameworks @ https://en.wikipedia.org/wiki/List_of_Java_frameworks You will see there are lots of small usefull frameworks as well, some of which you may even have used already. Frameworks like JUnit, Mockito JodaTime, Lombok, SonarLint/SonarQube as example are pretty commonly seen in projects. And those are not so big that it takes allot of time to use the basics.

I would just take a look through the whole list, see if you have seen or maybe even used some before, and check out some of the frameworks to see if you like them.
Only thing I see wrong right now is that you print this.student in the displaycourseinfo instead of this.enrolledstudents (You may have to find a way to print a list correctly).
your course class is now holding both a student object and a enrolledstudents list right now, but it could be this was your intention to have that student be the teacher of the course or something?

And yes, when you have more students and courses to work with you may want to have a way of selecting the right ones. Something in the trend of if student.name = ?? then do this. Same for course.
6 months ago

Daniel Demesmaecker wrote:I you have a seperate class for your courses who have enrolled students in them it's not enough to pass only the student. You have to create an array who keeps track of the course and the enrolled students (I would use a hashmap).
so you have to pass both student and course, then in the function looping the hasmap searching for the course and adding the student, but the way I descriped before is way easier.

A Hashmap would be a neat solution, but considering this is an assignment I think OP is more looking for a simple list<Student> implementation in the Course object.

If you want to add a student to your course, you would need a list/array in your course object to save this in.
Then when you want to add the student you want to call this course object and run a method that adds the student you have given to this list/array.

Considering the code from your first code, something like this  'c.addStudent(yourStudent);' in the for loop. Be aware that your for loop is running over all courses in your Clist, so now the student would be enrolled to all courses if you implement the suggested method. I will let you try to figure that part out for yourself for now, let us know if you can figure it out or not
6 months ago
Your current code when the commented line is not commented will try to add your student into the list of courses. Now a list of Courses and Students mixed together would indeed not be what you want and if Clist is of type Course would even give you an error.

There are multiple ways of solving this, you can either give the Student an empty list of Courses where you add the courses to the list in the Student object. Or you can add an empty list of students to your Course and add the student to a students list in the Course object.
You can also let both objects have a list where you add persons to courses and courses to persons. But: then you have double data which would be redundant and can result in inconsistent data. Since person has its own list, and course has its own list.

You may want to think first about what approach you would like to make, and write it down to get an idea.
6 months ago
If this is designed by a man, he must've been a god at reading women right.
We have 2 ovens at home, 1 simple digital one, and this complex weird one with a rotating button that can be pushed in, pulled out and who knows what magic tricks doing all kind of different functions and settings.

My wife understands that weird one and doesn't get the digital one. I understand the simple one but feel lost at the complex weird one to me.
6 months ago

Junilu Lacar wrote:

Koen Ursem wrote:My guess is either your current app location is read with single backlashes where there is a '\u' in the path name from a folder or file starting with a 'u'. Or there is a property in one of the config files that points to a folder with a occurrence of '\u' like '\user' in the path.

That is a very good guess. In fact, it's what I would call an "informed and highly-probable guess." Way to think outside the box, Koen! In fact, I'm giving you some Thanksgiving Pie for it, even if it doesn't pan out (which I think it will).

@OP: If you can run the grep command, use it check if your properties file contains "\u" at all. On Windows, I believe the equivalent command is "findstr", at least according to what Google tells me.

Well thank you kindly!
I bet most programmers have at least once dealt with issues on paths with slashes and backslashes when using other systems. I had almost the same error a year ago on a vm machine where I fixed a path in the code replacing the \ for a double \\. In this case it does seem a bit different in that there could be a configuration reader that reads the path as a string at first with the properties load function, considering the file type and system it probably sees \u in the string as a encoded Unicode character that would be followed by a digital for the Unicode character.

So if I am indeed correct OP has to find a way to either escape it in the config, save the config file in a different format (UTF-8? not sure on it), or if it is a directory avoid the the occurrence of \u in the folders and file name.
Otherwise the code would have to be changed to escape it if that wouldn't work, but from the story I understand OP is not directly able to change this.
6 months ago
Is your application in a folder starting with a 'u' like c:\user\myapp for example?

In some systems the \u in user gets faulty recognized as a Unicode character.
But it could also be that in one of the xml/config files there is a path named with \ instead of \\ or /.

My guess is either your current app location is read with single backlashes where there is a '\u' in the path name from a folder or file starting with a 'u'. Or there is a property in one of the config files that points to a folder with a occurrence of '\u' like '\user' in the path.
6 months ago
Edit(cant add to previous message): It is by the way not because the constructor is a string, but because you have the String name; in the body of the class itself that it handles name as a string and cannot be set initialized as String again.
6 months ago
Yes would be this.name = name; without the String in front of it, since it is already defined as a String holding object. For the rest your Employee class looks fine.
6 months ago
I have spotted the following when I run your code,

the first is that you mix up the int[] and string[] arrays in your method. Once you instantiate it as a string or int, you either have to convert those and save it in a different variable or keep it the same type.

The 2nd is that you created a method signature (non declared method) to be overwritten by classes that could implement/extend the class, so the method can not have a return.
Example of the difference:
public static void overrideMe;
public static String giveMeString(){ //code };

When you managed to fix these, you may want to look at how to change line 13 to call a static method.
6 months ago
Since you are working with char inputs, you may also like the methods that the Character class in java gives you.

You can do for example:
and some more useful methods.

which are returning true or false when a char is given.

7 months ago