EatTheBlocks Forum

Hotel menu and Order system

Dear,

i am new to solidity and program, i have try to create a contract in Solidity for the hotel menu list and order list,can you help me to correct.
pragma solidity ^0.5.0;

contract Menu{

uint256 public BookingId;

// address public Guest;

// uint256 Qty;

uint256 nextid=1;

struct Menuitem{

uint256 Sno;

string name;

uint256 Price;

}

struct orderedfood{

Menuitem Sno;

Menuitem name;

Menuitem Price;

}

mapping (uint256 => Menuitem) public menu;

Menuitem[] itemarray;

orderedfood[] order;

function additemtomenu(string memory name, uint256 price) public{

itemarray.push(Menuitem(nextid,name, price));

nextid++;

}

function addmenuitemtoorder(string memory name,uint256 price,uint256 Sno) public{

for(uint256 i = 0; i<=itemarray.length;i++){

if(itemarray[i].Sno == Sno){

order.push(orderedfood(itemarray[].nextid,Menuitem.name,Menuitem.Price));

}

}

}

function updateordereditem(uint256 Sno,string memory name) public{

for(uint256 i = 0; i<=itemarray.length;i++){

if(itemarray[i].Sno == Sno){

order[itemarray[i]].name = name;

}

}

}

function getorderlist(uint256 Sno) view public returns(orderedfood[] memory){

for(uint256 i = 0; i<=itemarray.length;i++){

if(itemarray[i].Sno == Sno){

return (order[itemarray].Sno, order[itemarray].name, order[itemarray].price);

}

}

}

}

Not quite sure what is your question here.

  • I would recommend to use Markdown to format your code
  • and Read this thread to understand how to ask a good question.