-
-
Notifications
You must be signed in to change notification settings - Fork 127
Added print() method to PMatrix (Fixes #811) #1355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Added a default method to print matrix data.
catilac
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Sumamasonia Thank you so much! So my review is this:
The solution is a little simpler, than what you have, but it's the right idea. Since we're dealing with the interface of PMatrix java's polymorphism allows you to simply declare public void print(); and it will know what to do. Once you make this change i'll merge it in!
|
Hi @catilac, I have finished the updates. Added the print() declaration to the PMatrix interface and implemented formatted toString() methods in both PMatrix2D and PMatrix3D. This makes the solution simpler and polymorphic as suggested. Ready for your review! |
|
@Sumamasonia Hi! Can you help me understand the changes you made in |
|
Hi @catilac! The reason I updated the implementations is to leverage polymorphism properly as you suggested. Previously, both classes had their own independent print() logic. By adding public void print() to the PMatrix interface, I added the @OverRide annotation to the existing methods in PMatrix2D and PMatrix3D to explicitly link them. Also, I refactored the formatting logic into toString(). This makes the code cleaner and allows developers to use System.out.println(matrix) as well as matrix.print(), with both using the same formatting logic. Let me know if you’d prefer me to revert the implementation changes and keep the original print() methods as they were! |
|
@Sumamasonia ohhhh I see what you've done. That's really cool. Sorry I didn't understand it |
Hi,
I noticed this issue (#811) was inactive for a while, so I went ahead and implemented the fix.
Changes:
Added default print() method to PMatrix interface.