I want to print a varValue of an object with it's related review objects.

This is really frustrating. I would like to print out the name of the game object alongside the comment objects related to them. The reviews/replies are called by reference of the the object. I can tell the compiler knows the reference because it groups reviews and replies by game.

I want it like this:

Reviews for The Witcher 3 --- the part I want, the rest is easy.

Rev1/ User ID: u1; Name: JD; "This game is timeless!"

Rep1/ User ID: u2; Name: Boss; "Really? You run around in imaginary fields hunting for imaginary creatures...lame."

Rep2/ User ID: u1; Name: JD; "Blah, blah, something."

Other games ect...

Reviews group perfect for game type and replies group perfectly under the review. But I can't find a way to show the game the reviews are for. Is there a way?

Any help would be great.

review and reply methods are called like this:

game1.addReviews(review1);
review1.addReply(reply1);
reply1.addReply(reply2);

....

public class Comment {

protected List<Comment> reply = new ArrayList<Comment>();

private User user;
private String usrComment;

public Comment() {

}

public void addReply(Comment r) {

    this.reply.add(r);
}

@Override
public String toString() {
    return   this.user.getUsr() + '"' + this.usrComment + '"';
}

...

public abstract class Content {

protected List<Comment> Review = new ArrayList<Comment>();

private String ID;
private String Application_Name;

// constructor to take ID, name and price of app
public Content(String iD, String application_Name, double price) {
    super();
    ID = iD;
    Application_Name = application_Name;
    Price = price;
}
public void addReviews(Comment a) {

    this.Review.add(a);
}

}

...

public class Game extends Content {

private boolean isMultiPlayer;
private OS o;
private double Price = 0;

public Game(String iD, String application_Name, double price, boolean isMultiPlayer, OS o) {
    super(iD, application_Name, price);
    this.isMultiPlayer = isMultiPlayer;
    this.o = o;
}
}

1 answer

  • answered 2018-05-16 10:35 N Woods

    This was silly. The object (game) is the object calling the method and passing another object as an argument. So any method or value related to the calling game object can be accessed within the method called. I was using two advanced loops and recursion, so I may have confused myself a little.