[COURSE] Why making project on thing we didn't see?

Hello,

I’m kinda new and I find very frustrating to be asked to do a project with thing that’s never been explained in the course? Like for example, in the Java-Droid project, the last question is:
Create new instances and play around with the methods. Here are some ideas to get you started:

  • Create a energyReport() method that prints the instance’s batteryLevel .
  • Create another instance.
  • Create a method energyTransfer() that exchanges batteryLevel between instances.

The course never explain how to “communicate” between instance at all in the course and the video don’t even talk about this subject.
So why doing this ? I don’t feel it’s normal to go search on other website to understand how it work in a learning phase ?

It’s the same thing for the following project “Cumulative Project 2”, there no explanation at all. I have to see the video about how it’s done to get an explanation…

It wasn’t like that from the start, it was teaching then exercise.

Welcome to the community, superclink!:smile:

I had this problem before, I think you are stuck on the energyTransfer() part.

If you know which droids you have, you can make if() loops within energyTransfer() that checks if the names are the same. Like this:
assuming you had droids with names of droid1 and droid2

public void energyTransfer(string name, int amount){
  batteryLevel = batteryLevel - amount;
  if(name = droid1){
    droid1.batteryLevel = droid1.batteryLevel + amount;
  }else{
    droid2.batteryLevel = droid2.batteryLevel + amount;
  }
}

otherwise, you will need to give each droid and integer ID, and use a for-each loop to check which is getting charged.

Hope this helps! Feel free to contact me if you are still confused.:+1:

I share superclink’s exasperation. I’m deep in Cumulative Project 2 in the Build Basic Android Apps and feel lost amongst techniques and methods that have not been fully explained or critically, practiced. Yeah, I can google, and have, but I’m not paying $40 a month to google. The early lessons were in the stream excellent. Step by step and the best thing was the correct code was available to work through when truly lost, but CP2 is dense and confusing and gives me pause in continuing this course. Please make the solution code available.

Found the walk-through vid. Useful. Thanks.T

@timmyred7071698905, you NEVER post complete code. It does not help others learn. If you are struggling, we are here to help. But we will never give you the full answer to a problem.

However, The solution code is available through the earlier tasks in the course. and the full answer being supplied was very helpful in locating and figuring out my own errors. The project can be wiped (another excellent feature) and attempted again with these comparative learnings at hand.
The request was not to “post” complete code, but to make a similar solution device available within the later projects.

One of the main reasons I prefer sorting through a solution myself is that learning is that I’ve found online forums to be beacons for people who like to make proclamations about learning styles and even occasionally do it in ALL CAPS, both of which for me, are the antithesis of help.

Sorry buddy, could you reword your post in a way that is a little easier to understand? I understand that it is easier to find a bug when you have the “correct” code in front of you, but it’s not helpful to do it all the time. And I think you meant that you can see earlier discussions. Yes, that is true, and you can cheat that way. But you can see the mistakes others made and learn from them. Remember, at the end of the day, your actions only benefit and hurt yourself. :wink:

Hello @timmyred7071698905 and welcome to the forums!

If you have a specific question (or even questions about a concept in general), I’d be glad to help!

Please post the link to the project exercise and any of your related code. :slight_smile:

1 Like

Thanks Victoria. Much appreciated.
I’m still getting my head around how the different Classes interact and I’ve hit a wall on the Cumulative project 2. When test printing data I’m getting “Null” instead of the quoted question text. Can’t see the forest for the trees at present, so nay tips would be great.

It’s Step 9 of
https://www.codecademy.com/paths/introduction-to-android-with-java/tracks/programming-logic/modules/cumulative-project-2/projects/question-java

Code

(Apologies for the mass code post, but I can’t locate where or why the Question is being returned?

Question.java

/*public class Question {
int correctAnswer;
int playerAnswer;
int imageId;
String questionText;
String answer0;
String answer1;
String answer2;
String answer3;

Question(int imageIdentifier, String questionString, String answerZero, String answerOne, String answerTwo, String answerThree, int correctAnswerIndex ){

imageIdentifier = imageId;
questionString = questionText;
answerZero = answer0;
answerOne = answer1;
answerTwo = answer2;
answerThree = answer3;
correctAnswerIndex = correctAnswer;
playerAnswer = -1;
}
}
*/
Android OS.java

/*
public class AndroidOS {
public AndroidOS() {
System.out.println(“AndroidOS Booting Up…”);
}

public void runQuizApp() {
    Question question1 = new Question(921238, "What line is he about to deliver?", "Twenty five, three tonnes of him", "Here's to smimmun' with bow-legged women", "Twelve hundred men went into the water", "Pretty good stuff huh chief!", 1);

Question question2 = new Question(107343, “What words are graffit’d on this?”, “Oh no, help!”, “Get me outa here!”, “Dinner!”, “Help shark!”, 3);
Question question3 = new Question(748294, “What’s the last instruction for Brody’s knot?”, “Comes out of the cave again”, “Little eel swims in the cave and done”, “Goes around the edge”, “and pull tight”, 0);
System.out.println("Question 1: " + question1.questionText);

}
public static void main(String[] args) {
    System.out.println("Starting: AndroidOS");
    AndroidOS androidOS = new AndroidOS();
    androidOS.runQuizApp();
    }

} */

Take a look at this line in your Question constructor. You’ve got the variables the wrong way around (should be assigning questionString to questionText). This means that questionText will have the default value of null since it was never assigned a value.

For future posts, please use the </> button to format your code. :slight_smile:

Ah! Thanks so much. Code posting guidelines noted.

1 Like