Using Class Api's

I'm in an AP Compsci class except I've like almost forgot anything so I was wondering if it was possible I could get some help/advice on how to do this?
No description
12 Replies
JavaBot
JavaBot3mo ago
This post has been reserved for your question.
Hey @Crawl! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
Crawl
CrawlOP3mo ago
if there was something I forgot to include please notify me
Crawl
CrawlOP3mo ago
this is what I have written so far
No description
Madjosz
Madjosz3mo ago
It's System and not system. Java code is case-sensitive.
ayylmao123xdd
ayylmao123xdd3mo ago
also check code format should be
"Name: " + stud1.getName()
"Name: " + stud1.getName()
etc
Madjosz
Madjosz3mo ago
It's not clear what you are supposed to do from the assignment.
𐌋okesh
𐌋okesh3mo ago
you don't have to do anything. It is clear that this one is just to make you comfortable and familiar with designing a class and accessing it's properties and methods. I've stuck into such things so much. My best advice is keep going, see the bigger picture. Don't just pick small things and sit down stressed out that you don't understand it all. all you have to do is, feel free to declare variable (which are used to mark/describe a property of a class and hence a field for an instance of that class) and functions (which are used to mark/describe a method which in simple works means behavior of an object/instance of your class). Design Student, BankAccount, Course class that mimic real world Student, BankAccount, Course. This assignment teaches you about getters, setters, properties, methods, constructurs, and how you access them from an instance. I may have repeated some sentences in different ways, sorry for that, that's the best I could explain. and IMHO that's all this assignment is about. Off-topic: I personally never understood why properties like name is made private and then you provide accessibility for name too. Why not just make name public. but I guess that has meaningful reasons such as semantics, and all. idk.
ayylmao123xdd
ayylmao123xdd3mo ago
its not only semantics its also security
𐌋okesh
𐌋okesh3mo ago
please explain. if you make name private but then you provide a public getName and setName, then I might be blind to see the point tbh.
ayylmao123xdd
ayylmao123xdd3mo ago
simplest example you have a field named age in some class and you have a getter and setter and the field is private and you wanna change the fields value to something in the setter you add a validation so that the age cant be below 0 whereas if the field was public you could set it to -9999999 and skip the validation another case is when you dont want the field to be changed at all so you just use a getter and dont make a setter
Madjosz
Madjosz3mo ago
Also you cannot reference fields with a Method Reference Expression. While it is perfectly fine to write stream().map(Person::getName) you'd always have to write a lambda with a field: stream().map(p -> p.name).
JavaBot
JavaBot3mo ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one. In case your post is not getting any attention, you can try to use /help ping. Warning: abusing this will result in moderative actions taken against you.

Did you find this page helpful?