我只是在做一些事情作为考试的练习,但是有一点我无法理解,就是使用属于一个类的变量,在另一个类中.
我有一个Course课程和一个Student课程.课程存储所有不同的课程,我只想要能够做的是在课堂学生中使用课程的名称.
这是我的课程课程:
public class Course extends Student
{
// instance variables - replace the example below with your own
private Award courseAward;
private String courseCode;
public String courseTitle;
private String courseLeader;
private int courseDuration;
private boolean courseSandwich;
/**
* Constructor for objects of class Course
*/
public Course(String code, String title, Award award, String leader, int duration, boolean sandwich)
{
courseCode = code;
courseTitle = title;
courseAward = award;
courseLeader = leader;
courseDuration = duration;
courseSandwich = sandwich;
} …Run Code Online (Sandbox Code Playgroud) 我正在按照我所拥有的书中的教程进行操作,但想向表中添加一些额外的列。我添加了“买入”和“卖出”列,并且在每个列中我想显示一个按钮。我不确定如何做到这一点,这可能吗?
这是带有表格的页面中的代码:
<?php // Example 21-9: members.php
include_once 'header.php';
if (!$loggedin) die();
echo "<div class='main'>";
$con=mysqli_connect("localhost","root","usbw","stocktrading");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM stocks");
echo "<table border='1 '>
<tr>
<th>ID</th>
<th>Name</th>
<th>Price</th>
<th>Buy</th>
<th>Sell</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr>";
echo "<td>" . $row['id'] . "</td>";
echo "<td>" . $row['name'] . "</td>";
echo "<td>" . $row['price'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Run Code Online (Sandbox Code Playgroud) 我在C#中有一个WPF应用程序,对于我的一个文本框,输入然后自动转换(Celsius到Fahrenheit).当你输入一个数字,它工作正常,但一旦删除输入数字的所有数字,程序崩溃.我想这是因为输入格式是'无效',因为它只是试图转换什么?我对如何解决这个问题感到困惑,任何帮助都将不胜感激,谢谢!
这是我在应用程序中的代码:
private void tempC_TextChanged(object sender, TextChangedEventArgs e)
{
tempC.MaxLength = 3;
Temperature T = new Temperature(celsius);
T.temperatureValueInCelcius = Convert.ToDecimal(tempC.Text);
celsius = Convert.ToDecimal(tempC.Text);
T.ConvertToFarenheit(celsius);
tempF.Text = Convert.ToString(T.temperatureValueInFahrenheit);
}
Run Code Online (Sandbox Code Playgroud)
这是我创建的API的代码:
public decimal ConvertToFarenheit(decimal celcius)
{
temperatureValueInFahrenheit = (celcius * 9 / 5 + 32);
return temperatureValueInFahrenheit;
}
Run Code Online (Sandbox Code Playgroud) button ×1
c# ×1
call ×1
class ×1
html ×1
html-table ×1
java ×1
php ×1
validation ×1
variables ×1