Help with making a book class

  • (3 Pages)
  • +
  • 1
  • 2
  • 3

36 Replies - 3238 Views - Last Post: 20 September 2014 - 02:12 PM Rate Topic: -----

#31 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Help with making a book class

Posted 20 September 2014 - 01:20 PM

You forgot to post the errors.
Was This Post Helpful? 0
  • +
  • -

#32 DroidsEatApples   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 17-September 14

Re: Help with making a book class

Posted 20 September 2014 - 01:22 PM

My bad!

Here they are:

Multiple markers at this line
- Syntax error on token "(", ; expected
- Syntax error on token ")", ; expected
- void is an invalid type for the variable


Not sure what this means. I am comparing my code to my classmates and it looks similar, but his passes with no errors and this error is holding me back.

Not sure why..
Was This Post Helpful? 0
  • +
  • -

#33 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Help with making a book class

Posted 20 September 2014 - 01:29 PM

You need to post the full error details, not just paraphrase them. We need to know these error details, which include the line numbers, together with the code that the errors refer to.
Was This Post Helpful? 0
  • +
  • -

#34 DroidsEatApples   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 17-September 14

Re: Help with making a book class

Posted 20 September 2014 - 01:30 PM

View Postandrewsw, on 20 September 2014 - 01:29 PM, said:

You need to post the full error details, not just paraphrase them. We need to know these error details, which include the line numbers, together with the code that the errors refer to.


Well this error pertains to the last line of my code:

public class Trilogy {

	public static void main(String[] args) {
	}

	// variables
	private Book book1;
	private Book book2;
	private Book book3;
	private String trilogyName;
	
	
	// getters and setters for books
	public Book getBook1() {
		return book1;
	}

	public void setBook1(Book book1) {
		this.book1 = book1;
	}

	public Book getBook2() {
		return book2;
	}

	public void setBook2(Book book2) {
		this.book2 = book2;
	}

	public Book getBook3() {
		return book3;
	}

	public void setBook3(Book book3) {
		this.book3 = book3;
	}

	// getter and setter for trilogyName
	public String getTrilogyName() {
		return trilogyName;
	}

	public void setTrilogyName(String trilogyName) {
		this.trilogyName = trilogyName;

	}

	// getter and setter for name
	public String getName() {
		return trilogyName;
		
	public void setName(String trilogyName) {
		this.trilogyName = trilogyName;
	}

	}

}


Was This Post Helpful? 0
  • +
  • -

#35 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Help with making a book class

Posted 20 September 2014 - 01:32 PM

This

Quote

- Syntax error on token "(", ; expected

is a simple syntax error: a missing, or extra, bracket, or an extra comma, etc..

Yes, you are missing the closing bracket for your getName() method. You need to look not just on the line that the error message refers to, but some lines before it as well.

The bracket on line 56 might then be unnecessary.
Was This Post Helpful? 0
  • +
  • -

#36 DroidsEatApples   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 17-September 14

Re: Help with making a book class

Posted 20 September 2014 - 01:34 PM

Why thank you so much. Yeah I added an extrea bracket and that completes my assignment!

THANKS FOR ALL THE HELP :D

This post has been edited by andrewsw: 20 September 2014 - 02:11 PM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#37 andrewsw   User is offline

  • no more Mr Potato Head
  • member icon

Reputation: 6957
  • View blog
  • Posts: 28,696
  • Joined: 12-December 12

Re: Help with making a book class

Posted 20 September 2014 - 02:12 PM

@OP You don't have to quote a previous reply every time, there is a large Reply button further down the page.

Anyway, glad you sorted.
Was This Post Helpful? 0
  • +
  • -

  • (3 Pages)
  • +
  • 1
  • 2
  • 3