Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 14 of 14

Thread: Bicycle Code - need a little help or tips to continue my homework

  1. #1
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Bicycle Code - need a little help or tips to continue my homework

    I create the following class: Rueda, Chasis and Bicicleta

    I need some tips and recomendation and examples to work with this program.

    I need to create a program where the object Bicycle will be create and then the object Bicycle ask to the user to enter the radio and weight of the Rueda (tire) and then ask to enter the height , lenght and weight of the Chasiss. the bicycle will be create at velocity of 0.
    Then thanks to the toString of the Classes Rueda and Chassis the program will show the weight and high of the bicycle.
    And finally the program need to use a loop to ask if you want to increase or decrease the velocity and for how much. every time the user enter a value the program will be show the actual velocity...
    Last edited by term204; April 1st, 2018 at 08:42 PM.

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    Do you have any specific problems you could ask questions about?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    How im able to configure the program to ask the user to enter the Rueda(tire) radio and weight, and the user can enter those values....

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    ask the user to enter ...
    Look at the Scanner class. It has methods for reading user input from a user.

    configure the program to
    Can you list the steps the program should take to do that?

    For testing the program, you could write a special testing class. The main() method in the testing class would take the steps needed to test your code.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    The 3rd code , Class Bicicleta have the main() method included.

    its a little difficult to explain.. i will try...
    In the Class Bicicleta needs 2 objects of the Class Rueda(tire in english) and 1 object of the Class Chassis in its atributes. And needs a Constructor where assigns the values of all his atributes. The class Bicicleta will have a default constructor where values are assigned to all the attributes of its attributes. What it means, to the attributes of the objects that are attributes of the class.

    Let me know if you understand..

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    Ok, pick one part of the assignment to work on.
    Try writing the code for that part. When you have problems, post some specific questions about that part.

    What it means, to the attributes of the objects that are attributes of the class.
    I assume there are variables defined in the class that define its attributes. The values for those variables are passed to the class via the class's constructor.
    For example from your code:
           Chasis(float lar, float alt, float pe)
    	{
    		largo = lar;
    		altura = alt;
    		peso = pe;
    	}

    If no arguments are passed to the constructor then a default value is assigned:
           Bicicleta()
    	{
    		velocidad = 0;
    	}
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    What it means, to the attributes of the objects that are attributes of the class
    I'm ask myself the same question..


    I assume there are variables defined in the class that define its attributes. The values for those variables are passed to the class via the class's constructor.
    That's i understand, but the instructions are not too clear.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    the instructions are not too clear.
    Ask your instructor for more information to clear up the instructions.
    If you don't understand my answer, don't ignore it, ask a question.

  9. #9
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    We already ask but he sent the instruction by email , using exactly the same words that he already said.

    I'm going to continue this tonight... i found different examples in the web that maybe can help me....

    if you can provide any idea i will apreciate, thanks for your help
    Last edited by term204; April 1st, 2018 at 08:44 PM.

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    Sorry, I have nothing more than what I have already said.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #11
    Junior Member
    Join Date
    Mar 2018
    Posts
    10
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    Quote Originally Posted by term204 View Post
    The class Bicicleta will have a default constructor where values are assigned to all the attributes of its attributes. What it means, to the attributes of the objects that are attributes of the class.
    First, this just means that the class Bicicleta should have a default constructor "Bicicleta()" and its attributes (ruedaDelantera, ruedaTrasera and cuadro) should be set with default values. To do that you also should set the attributes for each Rueda object (radio and peso) with some default values. The same for the Chasis object attributes (largo, altura, and peso).

    So an attribute of Bicicleta is ruedaDelantera and ruedaDelantera has an attribute called radio. So all attributes need to be set within the default constructor for Bicicleta.

    Second, from the instructions that you posted, the main() function should be moved out of the Bicicleta class. Move it to its own class like "BicycleAssignment" or "BicicletaPrograma". This will be "El programa".

  12. #12
    Junior Member
    Join Date
    Mar 2018
    Posts
    15
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    Thanks for the tips, still working on this program..

    --- Update ---

    How im able to calculate the total weight of the Bicicleta,

    Chasis weight(peso) + ruedaDelatera Weight(peso) + ruedaTracera Weight (peso)
    Last edited by term204; April 1st, 2018 at 08:44 PM.

  13. #13
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,165
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    Can the class's constructor be used to pass the class its values instead of calling the many set... methods?
    Now the values passed to the constructors are all 0s. Pass the real values instead.
    If you don't understand my answer, don't ignore it, ask a question.

  14. #14
    Junior Member
    Join Date
    Mar 2018
    Posts
    10
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: Bicycle Code - need a little help or tips to continue my homework

    I didn't get a chance to post earlier before term204's edits but it looks like you are on the right track
    Chasis weight(peso) + ruedaDelatera Weight(peso) + ruedaTracera Weight (peso)
    This is what I was going to post earlier... before your edits:

    To calculate the total weight of the Bicicleta, the Bicicleta class should have a method called something like getTotalWeight(). This will return the total weight value.

    The Rueda class should have a method like getRuedaWeight(). The same goes for the Chasis class.

    That way from Bicicleta.getTotalWeight() you can call Rueda.getRuedaWeight() for each of the tires and add it to the weight of the Chasis class.

    These are just the paths to the methods you would use. In your code you would use the actual instance variable. So something like: ruedaDelatera.getRuedaWeight()

    The toString() method would be implemented in the same way. That way all you do from the BicicletaPrograma class is call miBicicleta.toString().

    There should be no need to have class variables for the ruedas and chasis in the BicicletaPrograma. That would be stored in the Bicicleta class.

    Anyways some of this may not apply anymore. Hope that helps.

  15. The Following User Says Thank You to User2009 For This Useful Post:

    term204 (April 11th, 2018)

Similar Threads

  1. [SOLVED] Continue statement?
    By Elyril in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 22nd, 2014, 03:20 PM
  2. Help with my code for homework assignment, I don't know how to fix it!
    By maxman190 in forum What's Wrong With My Code?
    Replies: 8
    Last Post: October 19th, 2013, 03:01 AM
  3. bicyclejava.BicycleJava class wasn't found in Bicycle.java project
    By Onemoonrising in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 12th, 2013, 08:49 PM
  4. ...differ in length error; homework starter code not working.
    By mwebb in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 10th, 2011, 12:20 PM