Jump to content

Variable and OOP questions


Fire Dragon
 Share

Recommended Posts

Hi!I have some questions about variables and OOP.Here:1.Can create something like this with variables.variable 1: value=100variable 2:value=10Then when user presses button, variable 2 decreses variable 1 using it's own value.Like 100-10=90.After this,it changes it's own value to 0.(or decreases it own value using it's own value.Sounds confusing I know.)Code must work this kind always,if user changes variable 2's value,it decreases variable 1 using it's own value.Even it is 14,78,66 etc.2.About OOP,if I create value for my object,like 100,can I decrease or increase it like this way:

function computer(height,width,weight){this.heigth = height;this.width = width;this.weight =weight;}computer1 =new computer("80","60","20")computer1.width = "186";

And can I place event,what happens when computer.width = "0" ?Or can I use - and + operators with objects same way than variables?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...