homework 1 for the lesson
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Niki_homework_1/Niki_homework_1.sol

71 lines
1.7 KiB

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.11;
contract Cakery {
uint256 public cakeportfolio;
address public admin;
uint256 private fixedcosts;
uint256 private variablecosts;
uint256 public soldqty;
uint256 public price;
uint256 private income;
string private correct_password;
mapping (uint256 => string) internal mintmessage;
mapping (uint256 => address) internal mintaddress;
uint256 public mintcount = 0;
constructor() {
cakeportfolio = 10;
fixedcosts = 50;
variablecosts = 30 * 20;
soldqty = 30;
price = 100;
income = soldqty * price;
admin = msg.sender;
}
function showincome () public view returns (uint256) {
return income;
}
function add(uint256 sold, uint cost) public pure returns(uint) {
return sold + cost;
}
function showvariablecost () public view returns (uint256) {
return variablecosts;
}
function showprice () public view returns (uint256) {
return price;
}
function set_password(string memory _password) external {
require(msg.sender == admin);
correct_password = _password;
}
function mint(string memory _message) external payable {
require(msg.value >= price);
require(msg.sender == admin);
mintcount = mintcount + 1;
mintmessage[mintcount] = _message;
mintaddress[mintcount] = msg.sender;
}
function WhatIsTheHash(uint256 _mintnumber) public view returns (string memory message_, address sender_){
return(mintmessage[_mintnumber], mintaddress[_mintnumber]);
}
}