subject

In Java Create a class named TreasureBox that contains:
(Be sure to set the appropriate access modifiers – private/public)
a. A public static double field name PTS_PER_GOLD_COIN. Set this constant to 15.0
b. A public static double field name PTS_PER_SILVER_COIN. Set this constant to 7.5
c. An int data field for the number of gold coins in the box (can be negative or
positive).
d. An int data field for the number of silver coins in the box (can be negative or
positive).
e. A double data field for total value of points of the coins contained in the treasure box
f. A private method named updateTotalPoints that has no parameters and no return
values. This method updates the attribute for the total value of points in the
treasure box based on the number of gold and silver coins and the points per each
coin. Be sure to use the constants and do not ‘hard code’ the values 15 and 7.5 in
this method. This method is an example of a helper function to be used by ALL
methods that need to update the total values of points in the treasure box.
g. A constructor that accepts two values and initializes both attributes in the following
order: number gold coins and number of silver coins. The constructor should
update the attribute for total number of points based on the number of gold and
silver coins in this treasure box. (Use your helper function!)
h. A constructor that accepts no values and initializes both the number gold coins and
number of silver coins to 0. This constructor should call the constructor you created
in the previous step with the appropriate values.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:00
If you embed a word table into powerpoint, what happens when you make edits to the embedded data? a. edits made to embedded data change the data in the source file; however, edits made to the source file will not be reflected in the embedded data. b. edits made to embedded data don't change the data in the source file; however, edits made to the source file will be reflected in the embedded data. c. edits made to embedded data don't change the data in the source file, nor will edits made to the source file be reflected in the embedded data. d. edits made to embedded data will change the data in the source file, and edits made to the source file will be reflected in the embedded data.
Answers: 1
question
Computers and Technology, 22.06.2019 02:00
Aletter or menu command that starts an action when the user presses the designated letter and the alt key together is called what?
Answers: 1
question
Computers and Technology, 22.06.2019 22:00
Consider the following declarations (1, 2, 3, 5, 7)class bagtype{public: void set(string, double, double, double, double); void print() const; string getstyle() const; double getprice() const; void get(double, double, double, double); bagtype(); bagtype(string, double, double, double, double); private: string style: double l; double w; double h; double price; }; a.) write the definition of the number function set so that private members are set according to the parametersb.) write the definition of the member function print that prints the values of the data membersc.) write the definition of the default constructor of the class bagtype so that the private member variables are initialized to "", 0.0, 0.0, 0.0, 0.0, respectively d.) write a c++ statement that prints the value of the object newbag.e.) write a c++ statement that declares the object tempbag of type bagtype, and initialize the member variables of tempbag to "backpack", 15, 8, 20 and 49.99, respectively
Answers: 3
question
Computers and Technology, 23.06.2019 06:30
Which option correctly describes a dbms application? a. software used to manage databases b. software used to organize files and folders c. software used to develop specialized images d. software used to create effective presentations
Answers: 1
You know the right answer?
In Java Create a class named TreasureBox that contains:
(Be sure to set the appropriate access...
Questions
question
Chemistry, 01.07.2020 15:01