Skip to content
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

2021 Sem 1 Q1b - Approach + Naming of classes #383

Open
tzerenchua opened this issue Apr 27, 2021 · 3 comments
Open

2021 Sem 1 Q1b - Approach + Naming of classes #383

tzerenchua opened this issue Apr 27, 2021 · 3 comments
Labels
🧠 Finals Q&A Questions related to Finals

Comments

@tzerenchua
Copy link

tzerenchua commented Apr 27, 2021

Summary

Java file naming convention + approach

Description

There was a previous thread on the same question but since the focus of my question is a bit different I created a new subpart.

Sorry if this question sounds a bit trivial, but I'm a bit confused with regards to how to approach this question as well as the naming of classes. From my understanding, in part b we need to create a class that has a property of an object (for example, class B has a property other of type B while class C has a property of type C etc.)

Not sure if I may have misinterpreted the question but if that is the case, then how do I go about naming my classes? The question told us to save our code in a file called oop-b.java, but doesn't this mean that my file should have a line public class oop-b { (which will result in compilation errors) ? Or is there something I am missing here...?

Also for some reason I have a feeling this question is also related to generics (?) but I'm not too sure..

Screenshots (if any):

Screenshot from 2021-04-27 11-27-13

@tzerenchua tzerenchua added the 🧠 Finals Q&A Questions related to Finals label Apr 27, 2021
@gwajoon
Copy link

gwajoon commented Apr 27, 2021

The question is asking for a java file, so your code should be written as how you would normally! I don't think the public matters in this case as long as your class follows what the question is asking for and it works when you run your tests in (a).
And no I don't think this is a generics question, rather it is about inheritance whereby B extends A. Every other implemented class would extend A as well, so all instances of classes will be able to refer to any object of type A, B, C, etc I believe.

@rljw
Copy link

rljw commented Apr 27, 2021

For me, I named the classes by their direct names (ie class A{...}, class B {..} and so on). I do understand where your concern stems from, given that we were taught to name our classes the same way as our files. However, for this case I felt like the filenames were more for marking convenience since they followed a certain format throughout the paper, hence I thought it did not make sense to name it "class oop-b". Nonetheless, I believe that is more of a coding style issue so both ways of naming should still be functional. What is the error statement you get from the line public class oop-b{?
As for the question on generics, I don't think this question is on generics, but rather on inheritance instead

@tzerenchua
Copy link
Author

For me, I named the classes by their direct names (ie class A{...}, class B {..} and so on). I do understand where your concern stems from, given that we were taught to name our classes the same way as our files. However, for this case I felt like the filenames were more for marking convenience since they followed a certain format throughout the paper, hence I thought it did not make sense to name it "class oop-b". Nonetheless, I believe that is more of a coding style issue so both ways of naming should still be functional. What is the error statement you get from the line public class oop-b{?
As for the question on generics, I don't think this question is on generics, but rather on inheritance instead

Thanks all for your inputs! Just an update, I actually asked Prof Henry regarding the naming convention - I think the declaring the classes like class B, class C etc. should still be okay as I was told that there is no need to compile java codes.

As for my error statement, I think I implemented it wrongly but the error pointed to the hyphen, so I think it's just a matter of how we shouldn't have hyphens in the class names. But since there isn't a need for us to compile the code I think it shouldn't matter :)
Screenshot from 2021-04-27 15-56-48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🧠 Finals Q&A Questions related to Finals
Projects
None yet
Development

No branches or pull requests

3 participants