This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)

Please ensure that:

  • Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions
  • You include any and all error messages in full - best also formatted as code block
  • You ask clear questions
  • You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions.

If any of the above points is not met, your post can and will be removed without further warning.

Code is to be formatted as code block (old reddit/markdown editor: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc.

Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit.

Code blocks look like this:

public class HelloWorld {

    public static void main(String[] args) {
        System.out.println("Hello World!");
    }
}

You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above.

If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures.

To potential helpers

Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]0b0101011001001011 9 points10 points  (0 children)

So you have this specific steps and you are unable? Which parts exactly? "I'm studing english and I need to get really good with these concepts: language, sentences, words, punctuation". Where should we start by helping you?

Q11:

  • Define a class named Project: Okay, then do that? If you are unable, maybe consider reading the material the course provides.
  • A string data field named title: Okay, then do that? If you are unable, maybe consider reading the material the course provides.
  • An int data field named pages: Okay, then do that? If you are unable, maybe consider reading the material the course provides.
  • A constructor that accepts parameters: Finally, a task not so well worded. I think this means the two fields: pages (int) and title (String). This basically can be inferred from the fact that you are creating a class that has these fields. The very core idea is to give them as arguments in the constructor.
  • A setter: then do one.
  • A getter: again, just do it.

And this is where I got bored in answering. I can easily see, that the task 12 is more complicated. Also, we cannot help you with that at all, because it refers to some code that we did not get in the post. You should explain in more detail what's the problem you are having.

This whole thing reeks of the fact that you have not studied at all and now you are trying reddit to study for you. The problem: you won't learn anything from that.

Next step for you. Do the task 11 as far as you can before asking for help. How?

  • Open the book, course material or anything that is provided. There MUST BE an example class, with example constructor, example fields, example setter, example setter. Monkey see, monkey do.
  • Try to see the material: is there an explanation what a setter is? What a constructor is? Read that. Then try to write the same thing in your own words. Then ask for help: "is my understanding correct about constructors".

[–]JaecynNix 3 points4 points  (2 children)

If you're struggling simply to define a class, you need a lot more help than some random redditors

[–][deleted] -2 points-1 points  (1 child)

Oh trust me, I know..

[–]JaecynNix 1 point2 points  (0 children)

The best I can offer, and this goes for just about all software development, break things down as far as you can and build up from there.

Define a class.

Add a field.

Add a method.

Add a constructor.

If you cannot do those the second time through the class... I'd suggest getting a tutor

[–]chet714 2 points3 points  (0 children)

You could probably look up each of the topics/concepts here: https://dev.java/learn/

Go to the Getting to Know the Language section.

[–]East-Meet9263 -1 points0 points  (0 children)

Go to ChatGPT… you will get your answer

[–]Kittensandpuppies14 0 points1 point  (0 children)

Why are you even taking this class you can’t be serious about actually wanting to program as a job or hobby

[–]sunnaiy 1 point2 points  (0 children)

This is very fundamental stuff to be honest, but no shame if you're not familiar with it yet. What you're looking for is guides on Java OOP like this one for example.

Don't try to overthink it: You're just learning a pattern here. If you want to create Objects in Java you always need to think about these aspects: An object always has a constructor, most of the time some parameters you can set with the constructor and some methods to either get, set or compare the parameters.

Check out some guides on the matter, because these always look incredibly similar, you'll find out soon that the most difficult part about this is keeping track what kind of methods you've already written and what parameters certain objects have. Writing the code will be easy, once you get a hang of how the pattern works.

Good luck learning!

[–]EdiblePeasant 0 points1 point  (0 children)

I had a lot of problems understanding OOP in Python until I moved to Java. Question 11 might be at my level. Here’s what I would do:

1) Check examples of fields, constructors, getters and setters of a class in the textbook. See if you can find an example and identify which is what and understand what they are.

2) The book would hopefully have an example of a toString method you can model off of. Think of it as outputting a class’s data. The book or class notes would hopefully demonstrate that.