I have to Contracts habibconcert and changer , there is a method for changing the tickets_number in "habib concert" , it works fine when working just with the contract itself but i want to access to to it in another Contract "changer" so I made an object of the "habibconcert" in Changer Class and try to use it in
function changeTickets(uint new_tickets) returns(uint) {
firstObject.tickets = new_tickets;
uint updateTickets = firstObject.tickets = firstObject.tickets + new_tickets;
return ( updateTickets);
}
but i receive the these errors
browser/habibconcert.sol:12:11: TypeError: Expression has to be an lvalue.
firstObject.tickets = new_tickets;
^-----------------^
browser/habibconcert.sol:12:33: TypeError: Type uint256 is not implicitly convertible to expected type function () view external returns (uint256).
firstObject.tickets = new_tickets;
^---------^
browser/habibconcert.sol:14:33: TypeError: Expression has to be an lvalue.
uint updateTickets = firstObject.tickets = firstObject.tickets + new_tickets;
^-----------------^
browser/habibconcert.sol:14:56: TypeError: Operator + not compatible with types function () view external returns (uint256) and uint256
uint updateTickets = firstObject.tickets = firstObject.tickets + new_tickets;
^-------------------------------^
browser/habibconcert.sol:14:11: TypeError: Type function () view external returns (uint256) is not implicitly convertible to expected type uint256.
uint updateTickets = firstObject.tickets = firstObject.tickets + new_tickets;
^----------------------------------------------------------------------------^
Thanks in advance my two Contracts here below as following
pragma solidity ^0.4.0;
contract changer{
habibconcert firstObject = habibconcert(0xdc544654fefd1a458eb24064a6c958b14e579154);
function changeTickets(uint new_tickets) returns(uint) {
firstObject.tickets = new_tickets;
uint updateTickets = firstObject.tickets = firstObject.tickets + new_tickets;
return ( updateTickets);
}
}
contract habibconcert{
uint public tickets = 6;
address owner_of_tickets;
uint constant price = 1 ether;
mapping(address=>uint) public purchasers;
function habibconcert()payable{
owner_of_tickets = msg.sender;
}
function displayTickets_numbers()constant returns(uint){
return tickets;
}
modifier ownLycreature(){
require(msg.sender == owner_of_tickets) ;
// && tickets == 0
_;
}
function changeTickets_number (uint newtickets) ownLycreature{
tickets +=newtickets;
}
function buytickets(uint amount)payable{
if(msg.value!=(amount*price) || amount>tickets){
throw;
}
purchasers[msg.sender] +=amount;
tickets -=amount;
// if(tickets == 0){
// //selfdestruct(owner_of_tickets);
// }
}
}