我正在尝试更正此代码,以便它通过测试。\n我的尝试非常糟糕,因为我才刚刚开始学习软件逻辑的工作原理。
\n\nclass Item\n attr_reader :item_name, :qty\n\n def initialize(item_name, qty)\n @item_name = item_name\n @qty = qty\n end\n def to_s\n "Item (#{@item_name}, #{@qty})"\n end\n\n def ==(other_item)\n end\nend\n\np Item.new("abcd",1) == Item.new("abcd",1)\np Item.new("abcd",2) == Item.new("abcd",1)\nRun Code Online (Sandbox Code Playgroud)\n\n这是我的解决方案,但它不正确:
\n\nclass Item\n attr_reader :item_name, :qty\n\n def initialize(item_name, qty)\n @item_name = item_name\n @qty = qty\n end\n def to_s\n "Item (#{@item_name}, #{@qty})"\n end\n\n def ==(other_item)\n if self == other_item\n return true\n else\n return false\n end\n end\nend\n\np Item.new("abcd",1) == Item.new("abcd",1)\np Item.new("abcd",2) == Item.new("abcd",1)\nRun Code Online (Sandbox Code Playgroud)\n\n我希望 …
如果这是一个非常愚蠢的问题,我会提前道歉(我是php和mysql的新手.
基本上,我正在设置connect_to_mysql.php文件,如下所示(5:50):http://www.youtube.com/watch?v = YaII5QhNCH0
如下图所示:http: //www.developphp.com/view_lesson.php?v = 248
我正在使用MAMP.端口是80/3306然而我知道在MAMP起始页面上说,以下,它也不起作用:
MySQL的
可以使用phpMyAdmin管理MySQL数据库.
要从您自己的脚本连接到MySQL服务器,请使用以下连接参数:
主机:localhost端口:3306用户:root密码:root
这是我有的:
这是connect_to_mysql.php:
<?php
// Created BY Adam Khoury @ www.flashbuilding.com - 6/19/2008
/*
1: "die()" will exit the script and show an error statement if something goes wrong with the "connect" or "select" functions.
2: A "mysql_connect()" error usually means your username/password are wrong
3: A "mysql_select_db()" error usually means the database does not exist.
*/
// Place db host name. Sometimes …Run Code Online (Sandbox Code Playgroud)