Where to get waterproof pop up tents?

Java, need coding help?

  • Create a class called Tent (in the woods kind) that has the following attributes: Tent's model Number of people it can      sleep (whole number) Price (can be a fraction) Pop-up (yes or no) The class should have the following overloaded constructors: A constructor that takes      the Tent's model, number of people, Tent price, and pop-up boolean A default constructor that      sets the Tent's model to blank, and the other values to zero or false Write Get and Set methods for each attribute: model, number of people, pop-up, and price Do not allow number of people      to be less than zero Do no allow price to be      less than 15 or greater than 1000 Given the following Tent listings:          Tent's model         # persons         Price         Pop up             Coleman Sundrome         4         889.99         No             Wenzel Klondike         8         159.39         No             Genji Sports one-step         2         80.79         Yes       Create the program TentTest that will create two objects: first object must use the constructor for 4 values using the above table and the second object must use the default constructor then use the set functions to fill in the information.   Print the values in the objects in a nice column format (for Boolean value you can print it directly to say true or false).   Then take the average of the price for three Tents and print "Tent average price at  " and the average price (two digits to right of decimal point).   Create your UML for the class Tent first and put it in the comments at the top of your program (required). Don't forget your name at the top in comments also.   For the user's output use printfor DecimalFormat to format the fractional numbers (to only 2 digit to the right of the decimal point for length).

  • Answer:

    How far are you? EDIT You should make "noOfPeople" an int and not a String (also, please note the naming convention in Java - names of [non-constant] variables do not start with Capital Letters). Instead, consider making the variable "model" a String. "pop", on the other hand, should not be a String. Consider the fact that a tent can either be a popup or not and look at other data types, there is one which will always suit you better for "either/or" situations. as for controlling a tent's price and number of people, I would use conditional statements within the constructor that accepts arguments. if the value is not within the allowed range, throw an exception or simply display an error message and exit object creation. I hope this helps, and do post back if you get stuck. I will not give you a solution because that would stop you from learning on your own but I guess a hint or two won't hurt anyone. So keep at it, remember to read the docs and I hope to hear from you soon :)

Wilson Canda at Quora Visit the source

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.