Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!

Jan Kaczmarek

Greenhorn
+ Follow
since May 02, 2020
Jan likes ...
IntelliJ IDE MySQL Database Java
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
3
Given in last 30 days
3
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jan Kaczmarek

I decided to make method for this problem:

 

But I still think this is not correct way.
9 hours ago
Okay, so I decided to go with solution
class Lesson
Map<Student, ArrayList<Integer>> grades.

Im trying to make method that will add to the Map<Student,ArrayList<Integer>> Student that have got specific pesel(ID number). Im trying to use stream but its just checking if in my static ArrayList<Student> (that is pretending to be database) is any object with same String and if yes-it returns true or false.

Im reading oracle documentation and I cannot find any good solution. Am I missing something or there is no answer right there and I should make some own method? I find it kinda weird because it seems to be simple, daily problem so it should provide some tools to make it works.
12 hours ago
Hello,
Im making ControllerMenu to manage the transition between menus.


All my Menus have got only non-static methods and they are using instances from Service layers to connect/edit everything from data layers.
Individual menus should not require a ControllerMenu (so it cannont appear in any Menu constructor, as a class field and I think I shouldnt make an instance of it in these classes) . The dependency should only be one way. This is my solution for this problem:
https://pastebin.com/pepjBQN8
But in my opinion this code is pretty messy-a lot of instances for every method etc. Is there any another way to make it works? Most beautiful solution it would be "using methods (and make them non-static) from ControllerMenu without creating instances in every Menu" but I think its impossible.

3 days ago

Campbell Ritchie wrote:Somebody's sent me pie Thank you, JK



This portion of patience from all of you for my ignorance deserve a pie The pleasure was all mine.
Anyway I think the solution for this problem may be Map with multiple key-cause String method cant provide me enough service possibilities. I will post my solution in this topic for posterity if I will figure out how to do it:P
1 week ago

Campbell Ritchie wrote:

Jan Kaczmarek wrote:. . . Map<Student, ArrayList<Integer>> . . .

Depends how the hashCode() and equals() methods work in Student. If a Student object can change its state and therefore its hash code, you will never find it in the Map again.


It can. So the answer anyway is Lesson as a String, not a Lesson object. I will try to implement it this way- and find way to make all this Student/Teacher funcionality on it-if its not going to work as I want it to do-I will just post it here for some hints. Thank you for all your support and patience!
1 week ago
So maybe I will just ask-in Your opinion is it possible to add all this functionality with leaving Lesson(Subject) as a String. not an object? If yes-I will try to figure it out somehow ;)
1 week ago

Carey Brown wrote:Does your Repository have, or need to have, persistence behind it, such as files or database?



For now every Repository is just static ArrayList that stores objects created while the program is running(its provide me some kind of simulation of real program)  After I close the app-the Repository is cleared. After I will achieve all goals from logic(service) layer I will start developing real database-(mysql, hibernate will be included), later I will add interface and I will make it standalone application. Its for my self-learning purpose.

So I think I need Map that will  have as a key Object and accessing to add some value to it would be by Object.getSomehowANameInString ?
Something like:
"Map<Student, ArrayList<Integer>> gradesFromSpecificLesson"
but for adding value to specific Student, I would access to it by
lesson.put(Student.getName.matches(InputString), grades.add(InputInt)); ?
1 week ago

Carey Brown wrote:Do you really have a database behind this or are you just referring to a data layer that behaves like a database?
Do you really need a Lesson class? The key for the Lesson class is lessonName so why not just use the name as a String instead of enclosing it in another Object?

Here's a simple way of doing this where the Student owns the storage for grades.

This is an educated guess. I don't have access to your original requirements.



So maybe I will just input the architecture and what service my console app have.
ARCHITECTURE:


Admin logic:
Admin can create & delete:
Student account/Professor account.
Student logic:
Student can:
a)register to the specific Subject
b)check his grades from specific Subject
Professor logic:
Professor can:
a)create Subject
b)check Subject list
c)show list of Students registered to specific Subject
d)show average grades of all students from subject
e)show specific student grades from a subject
f)add grades from specific Subject to specific Student

Every (Subject/Professor/Student) object (excepted Admin) is created on application run and stored to static ArrayLists that pretending to be a database.

So in my opinion the only possible approach to finish this project is working with Subject/Lesson as an object-otherwise Professor methods wont work so yes, I think I need to make it with Map<Student(or Subject), ArrayList<String>> somehow
1 week ago

Carey Brown wrote:If Lesson is just a key of lessonName, then I'd go with option 1. MUCH simpler.


I tried few approach for this problem and I have got no idea how to implement this solution.
I made some short "demo version" of my console app to find some clear answer-but still I cant make head or tail of it. In my "big project" all data is stored in static ArrayList (Teacher, Lesson and Student objects) that why in this simple approach I added also ArrayLists.
Hastebin hosting: https://hastebin.com/ajitutabuv.csharp
Pastebinh hosting: https://pastebin.com/sw1PVqcm
So, theoretical -when I create Lesson object-it create also in it Map called grades that hold: Student as a key and as a value of it- ArrayList<Integer>.
So adding Student to specific Lesson and giving him a grades should be like this:
ADDING TO SUBJECT.
Create Student->add Student to Student database (static ArrayList<Student> in my data layer)-> Add somehow Student from database to Map<Student, ArrayList<Integer>> grades in specific Lesson-so on this point it should (I dont know how) create ArrayList<Integer> in this map that is going to be connected with this specific Student.

GRADE STUDENT(SPECIFIC).
Find matching  Lesson object from ArrayList<Lesson> - > Find matching key-(for example: Student ID, but on our purpose its going to be just a surname) Student surname in grades Map- so they key would look like this Student.getSurname,equals/matches "Provided by user surname"-> Adding somehow records to Value part connected to specific Student-without overwriting past grades that he have got.
I got this theoretical but I have got no idea how to change it into practice.
1 week ago

Carey Brown wrote:Does Lesson have any other attributes other than name?

You could have
The choice isn't exactly clear because it's not a straight forward has-a relationship. The relationship is more like a many-to-many relationship which would mean that you'd end up with a Grades class that has the Student and the Lesson as keys and containing a List<Integer> as its value.



In the begining I want to say thank you for answer!
Lesson its just a name, nothing else.
I think the idea with Grades class sounds great!
I never used thing like Map, I will read documentation about it but first I have got question about an overall idea.
Its going to look like this: Map<K1,K1,V>
where
K1-Student (for example ArrayList<Student> -cause its many of them)
K2-Subject
V-List<Integer>
?
So my Grades class that is holding that kind of map will generate individual List<Integer> for every Students and will connect it with specific Lesson?
One "record" of map in Grades will be like one color line:

So its like Many to one to Many relation?
One Grades object is generated for list of Students, specific Lesson and List<Integer> grades?
Or its more like:

So one Grade object is generated for specific Student in specific Lesson with List<Integer> grades?
In this case every Student will have Grades object for every Lessons he is registered to. So the Student class need to hold ArrayList<Grades>.
So map will look like this: Map<K1: Student(one object),K2 :Lesson(one object),V : List<Integer>> ?

For many to one to many :
Lets make some pseudocode, I want this to be clear for me:

And accessing this from Teacher side (for purpose of giving a grade) will look like this


EDIT no5:
I just checked-theoretically I cant have Map with 2 keys and 1 value but in practice I can create another class, for example GradesKey that is going to hold specific Student and specific Lesson as a class field. So this way it will look like this:
Grades<GradesKey, List<Integer>
So one GradesKey wil be linked to specific Student that is registered to specific Lesson and accessing will be kinda nested-cause to give any grade I need to access Grades->GradesKey->Student->studentID
..........................................->Lesson->lessonName
To access I need to connect with 2 branches that sprout up from GradesKey. Im not sure if I understand everything clear.
1 week ago
Hello,
Im making Teacher Managing application.
I have got 3 types of objects: Teacher, Student, Lesson
Teacher can create Lesson object. Every Lesson object is stored in ArrayList.
Teacher can add Student object to Lesson (register him).
Teacher can give grades for every specific Student from every specific Lesson-and this is my problem.
I have got no idea how can I connect Student with Subjects and give him individual array with grades from it.
In my head it looks like this: `` Example.

"John Smith" (Student object) is registered to "Math", "Chemistry", "Philosopy", "Biology" (Lesson objects)

   From "Math" he have got [1, 2, 4] grades,  
   From "Chemistry" he have got [5] grade,  
   From "Philosophy" he have got [2, 3, 4, 4] grades,  
   From "Biology" he have got [1,2,3,4,5] grades.
All grades ale given by teacher, he can give him another one -so I think its going to be ArrayList of grades in every Lesson object. But how the Student can have individual grades from specific Lesson? With one Student is simple-Lesson object would have in class fields ArrayList grades but what is the solution if I would have for example-another 10, 100, 1000 students and all of them have to have individual ArrayList with grades ( for example: JohnSmith.Biology.[1,2,3], JasmineLaw.Biology.[2,2,3], PeterSchmitd.Biology.[5,5,5])
How can I connect many Students object with many Lessons with his own, individual array with grades? I cant use any external database to hold this data. Plain Java.
1 week ago

Norm Radder wrote:Where did you get that idea? I think you should Use the tool that solves the problem.



Hello, thank you for your answer.
This question is the part of my homework about OOP.
I don't know if this question is clear to me-what is Object class object? I think its for example result of toString() method - so i dont find it useful unless i would @Override it.
3 months ago
Hello,
I have got (maybe silly) question but i spent some time googling without results:
Why its not good idea/its not worth to use Object class objects?
thank you in advance for your answer
3 months ago
Hello!
I have got pretty big problem with understanding how I should make this task.
Goals:
Input numbers till the last one is going to be bigger than previous (descending string)


So i think it should go like this:
1)Create "n" variable
2)Create list to keep the "n" variable
2)Start do-while loop to add numbers to list till n<previous.n

3)Break loop when when n>previous.n
I googled some things-I never used list before but it seems like this is only way to make this.
Is there any easier solution (easier=more basic)?
Thank you for help!
5 months ago