To create a SessionManager to save User objects in memory. It would be HashMap of HaspMaps.
It can be used as:
SessionManager MySessionManager= New SessionManager()
Student S1 = New Student ("Saurabh");
Student S2 = New Student ("Sandeep");
Student S3 = New Student ("Deepak");
//To create session
MySessionManager.createSession(S1);
MySessionManager.createSession(S2);
//SAVING S1 MARKS
Marks phyMarks = New Marks ("Physcis", 90);
MySessionManager.Save(S1, "Physics", phyisicsMarks); //Physics is the key
Marks chemMarks New Marks("Chemistry",85);
MySessionManager.Save(S1, "Chemistry",chemistryMarks);
Marks mathsmarks = New Marks("Mathematics",100);
MySessionManager.Save(S1, "Mathematics" ,mathsMarks);
//SAVING S2 MARKS
Marks phyMarks = New Marks ("Physcis", 90);
MySessionManager.Save(S2, "Physics", phyMarks); //Physics is the key
Marks chemMarks New Marks("Chemistry",85)
MySessionManager.Save(S2, "Chemistry",chemMarks);
Marks mathsmarks = New Marks("Mathematics",100);
MySessionManager.Save(S2, "Mathematics" ,mathsMarks);
//SAVING S3 MARKS. NOTE: SESSION OF S3 IS NOT AVAILABLE. SO FIRST SESSION OF
S3 SHOULD BE CREATED AND THEN DATA SHOULD BE SAVED
Marks phyMarks = New Marks ("Physcis", 90);
MySessionManager.Save(S3, "Physics", phyMarks); //”Physics” is the key
Marks chemMarks New Marks("Chemistry",85);
MySessionManager.Save(S3, "Chemistry",chemMarks);
Marks mathsmarks = New Marks("Mathematics",100);
MySessionManager.Save(S3, "Mathematics" ,mathsMarks);
///How to retrieve data
Out.Print ("Phyiscis Marks of S1," & MySessionManager.get(S1, "Physics").marks);
Out.Print ("Phyiscis Marks of S3," & MySessionManager.get(S1, "chemistry").marks);
IN REAL WORLD SCENARIO, S1, S2, S3 SHOULD NOT BE PASSED TO
MYSESSIONMANAGER. THEY WOULD BE OBTAINED FROM CONTEXT.
It can be used as:
SessionManager MySessionManager= New SessionManager()
Student S1 = New Student ("Saurabh");
Student S2 = New Student ("Sandeep");
Student S3 = New Student ("Deepak");
//To create session
MySessionManager.createSession(S1);
MySessionManager.createSession(S2);
//SAVING S1 MARKS
Marks phyMarks = New Marks ("Physcis", 90);
MySessionManager.Save(S1, "Physics", phyisicsMarks); //Physics is the key
Marks chemMarks New Marks("Chemistry",85);
MySessionManager.Save(S1, "Chemistry",chemistryMarks);
Marks mathsmarks = New Marks("Mathematics",100);
MySessionManager.Save(S1, "Mathematics" ,mathsMarks);
//SAVING S2 MARKS
Marks phyMarks = New Marks ("Physcis", 90);
MySessionManager.Save(S2, "Physics", phyMarks); //Physics is the key
Marks chemMarks New Marks("Chemistry",85)
MySessionManager.Save(S2, "Chemistry",chemMarks);
Marks mathsmarks = New Marks("Mathematics",100);
MySessionManager.Save(S2, "Mathematics" ,mathsMarks);
//SAVING S3 MARKS. NOTE: SESSION OF S3 IS NOT AVAILABLE. SO FIRST SESSION OF
S3 SHOULD BE CREATED AND THEN DATA SHOULD BE SAVED
Marks phyMarks = New Marks ("Physcis", 90);
MySessionManager.Save(S3, "Physics", phyMarks); //”Physics” is the key
Marks chemMarks New Marks("Chemistry",85);
MySessionManager.Save(S3, "Chemistry",chemMarks);
Marks mathsmarks = New Marks("Mathematics",100);
MySessionManager.Save(S3, "Mathematics" ,mathsMarks);
///How to retrieve data
Out.Print ("Phyiscis Marks of S1," & MySessionManager.get(S1, "Physics").marks);
Out.Print ("Phyiscis Marks of S3," & MySessionManager.get(S1, "chemistry").marks);
IN REAL WORLD SCENARIO, S1, S2, S3 SHOULD NOT BE PASSED TO
MYSESSIONMANAGER. THEY WOULD BE OBTAINED FROM CONTEXT.