The Student Room Group

Newbie Coders Chat

Scroll to see replies

Original post by john2054
Thanks 57, do you want paying for this? If i pass the mooc, i can drop you a dollar or two, if that would help?

Please ignore the comment lines 38-39-40 because I was not right about that. No need to pay me, for teaching and passing a student is the greatest reward. Knowledge is the greatest reward.
Original post by 571122
That's right, patience is critical in programming.


I corrected it and now it compiles. Check it out here:
http://pastebin.com/376JZa4c

Here are the answers to your questions:
- Yes, the second program is meant to compile and so it did after I amended it.
- It is supposed to demonstrate Objected Oriented Programming, and more specifically the use of functions (methods that return a value; a method is a function that belongs to a class), their return values and using those.

I ran the code now and the results are that it prints the following:


A few tips for further improvement:
- When you write code, always make sure you open and close your braces before you do anything else, otherwise you might forget to close some braces and then your code will not be valid.
- Don't add too much whitespace between code. Make it clean.
- Always indent correctly (normally it's 4 spaces per tab for good style). Whatever you write inside a code block needs to be indented, i.e.: code inside a class needs to be indented 4 spaces after the 'public class' line. Code inside a method needs to be indented 4 spaces after the 'public someMethod()' declaration

Shoes.java:13: error: illegal start of expression
public String goodShoes() {
^
Shoes.java:13: error: ';' expected
public String goodShoes() {
^
Shoes.java:16: error: ';' expected
Shoes gs= new Shoes("I really like your shoes!")
^
Shoes.java:21: error: illegal start of expression
public String badShoes() {
^
Shoes.java:21: error: ';' expected
public String badShoes() {
^
Shoes.java:22: error: ';' expected
Shoes bs= new Shoes("What are THOSE?")
^
Shoes.java:27: error: illegal start of expression
public static void main(String[] args) {
^
Shoes.java:27: error: illegal start of expression
public static void main(String[] args) {
^
Shoes.java:27: error: ';' expected
public static void main(String[] args) {
^
Shoes.java:27: error: '.class' expected
public static void main(String[] args) {
^
Shoes.java:27: error: ';' expected
public static void main(String[] args) {
^
Shoes.java:30: error: illegal start of expression
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: ';' expected
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: ';' expected
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: illegal start of expression
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: ';' expected
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:37: error: reached end of file while parsing
}
^
17 errors
rm: cannot remove ‘*.class’: No such file or directory

these are the runtime errors i get when i submit your code. Can you help me with any of these?
I'll look into it another day. Right now my time's up. Until then!
#include 'iwishiknewhowtocode'
Ye I done about 1 week on codeacademy, after the battlehip program thought lets try write one

http://pastebin.com/2c29UW7X

Very simple program but covers functions and loops and some external package. It took about 25-30 hrs of work. I found when I actually work at it rather than just ask on stackoverflow it feels way better when you figure it out yourself. Sometimes it helps to not just read the code over and over to see what's wrong but just get a paper and pen and think what youre trying to do and then putting it into code afterwards.

I dont think Im cut out for it though just seems so painful and my concentreation is ****

I don;t know what to do now, I thought a natural step would be to somehow store all my results from this program on a database and be able to recover them by date and then maybe install django and make this into a website. But I read that making a website with python is kinda long and unecessary so I might just play about with numpy and see wht I can do.
Original post by Nightowk
Ye I done about 1 week on codeacademy, after the battlehip program thought lets try write one

http://pastebin.com/2c29UW7X

Very simple program but covers functions and loops and some external package. It took about 25-30 hrs of work. I found when I actually work at it rather than just ask on stackoverflow it feels way better when you figure it out yourself. Sometimes it helps to not just read the code over and over to see what's wrong but just get a paper and pen and think what youre trying to do and then putting it into code afterwards.

I dont think Im cut out for it though just seems so painful and my concentreation is ****

I don;t know what to do now, I thought a natural step would be to somehow store all my results from this program on a database and be able to recover them by date and then maybe install django and make this into a website. But I read that making a website with python is kinda long and unecessary so I might just play about with numpy and see wht I can do.


well done night owl, what language is it in, and what software would i need to compile/run it?
Original post by john2054
Shoes.java:13: error: illegal start of expression
public String goodShoes() {
^
Shoes.java:13: error: ';' expected
public String goodShoes() {
^
Shoes.java:16: error: ';' expected
Shoes gs= new Shoes("I really like your shoes!":wink:
^
Shoes.java:21: error: illegal start of expression
public String badShoes() {
^
Shoes.java:21: error: ';' expected
public String badShoes() {
^
Shoes.java:22: error: ';' expected
Shoes bs= new Shoes("What are THOSE?":wink:
^
Shoes.java:27: error: illegal start of expression
public static void main(String[] args) {
^
Shoes.java:27: error: illegal start of expression
public static void main(String[] args) {
^
Shoes.java:27: error: ';' expected
public static void main(String[] args) {
^
Shoes.java:27: error: '.class' expected
public static void main(String[] args) {
^
Shoes.java:27: error: ';' expected
public static void main(String[] args) {
^
Shoes.java:30: error: illegal start of expression
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: ';' expected
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: ';' expected
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: illegal start of expression
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:30: error: ';' expected
System.out.println(+goodShoes+) and System.out.printn(+badShoes+)
^
Shoes.java:37: error: reached end of file while parsing
}
^
17 errors
rm: cannot remove ‘*.class’: No such file or directory

these are the runtime errors i get when i submit your code. Can you help me with any of these?

Remove all the comments from my code, that means all the /* and */ and // as well. Save it and compile it again.
Reply 207
Installed Linux on my laptop yesterday. For some reason whenever I try to put Linux on something it never goes as smoothly as it's supposed to, but got there in the end. :smile:

Decided I'd do a little development project. Not sure what yet though. I've been thinking about learning Python or perhaps coding a GUI program using C++.
written in python i just run it using command prompt
Original post by 571122
Remove all the comments from my code, that means all the /* and */ and // as well. Save it and compile it again.


For some reason 57, the shoes code is no longer showing the above errors, and only the following to runtime errors:

2 errors found:File: C:\Users\john2\Shoes.java [line: 12]Error: Illegal modifier for parameter goodShoes; only final is permittedFile: C:\Users\john2\Shoes.java [line: 13]Error: Illegal modifier for parameter badShoes; only final is permitted

here are lines 12 and 13 from the program:
public String goodShoes = shoes.goodShoes(); public String badShoes = shoes.badShoes();

I have exactly three days to sort this code out, and your help is much appreciated! John.
Original post by john2054
For some reason 57, the shoes code is no longer showing the above errors, and only the following to runtime errors:

2 errors found:File: C:\Users\john2\Shoes.java [line: 12]Error: Illegal modifier for parameter goodShoes; only final is permittedFile: C:\Users\john2\Shoes.java [line: 13]Error: Illegal modifier for parameter badShoes; only final is permitted

here are lines 12 and 13 from the program:
public String goodShoes = shoes.goodShoes(); public String badShoes = shoes.badShoes();

I have exactly three days to sort this code out, and your help is much appreciated! John.

Please post all of the code in pastebin (yes, I know I wrote it, but still do it) so that I can look what's really going on.
Original post by 571122
Please post all of the code in pastebin (yes, I know I wrote it, but still do it) so that I can look what's really going on.


here you go:

http://pastebin.com/nvPgrk6T

okay?
Original post by john2054

Remove 'public' from lines 12 and 13 and add the 'public' keyword before line 10.
Your public static void main should always be public.
(edited 7 years ago)
Original post by 571122
Remove 'public' from lines 12 and 13 and add the 'public' keyword before line 10.
Your public static void main should always be public.


When i remove that parameter, i get all of the error messages i posted in message 209, so i think i would like to keep it in thanks.
Original post by john2054
When i remove that parameter, i get all of the error messages i posted in message 209, so i think i would like to keep it in thanks.

It's not a parameter, but an access modifier. The explanation for why you can't have the 'public' keyword inside a method is beyond technical for what we're doing here.

However, there must be something you're doing that I'm not, because I just ran your code myself and it works perfectly. See here:
http://pastebin.com/KKaVFHnH
(edited 7 years ago)
Coding in Python because CS GCSE.
I also code Lua, because I make exploits for roblox, (and get paid).

But currently i'm trying to learn C# for Unity3D.
Original post by john2054
Can you please pastebin the code you are using, so i can see if it works on my machine?

Well, I just did, in the post you just quoted.
Original post by 571122
Well, I just did, in the post you just quoted.


Test Failed: One return statement
Test Failed: Two return statements
Test Failed: Two output statements in main method
Test Failed: goodShoes is called from the main method
Test Failed: badShoes is called from them main method
Test Failed: Correct output: goodShoes
Test Failed: Correct output: badShoes
Completion: 6/11

This is where it fails, if that is any help?
Original post by john2054
Test Failed: One return statement
Test Failed: Two return statements
Test Failed: Two output statements in main method
Test Failed: goodShoes is called from the main method
Test Failed: badShoes is called from them main method
Test Failed: Correct output: goodShoes
Test Failed: Correct output: badShoes
Completion: 6/11

This is where it fails, if that is any help?

You guys are doing Test-First Development? Man, that is an advanced practice and out of place for beginner programmers..

I would have to see all of your tests (all the code) to be able to judge it.
Original post by 571122
You guys are doing Test-First Development? Man, that is an advanced practice and out of place for beginner programmers..

I would have to see all of your tests (all the code) to be able to judge it.


It's okay 57, i'm now scraping a 50% pass for this unit, and whilst i would have have liked for more, a pass, is a pass, is a pass, as they say!

Quick Reply