题目:
学年学期:
课程名称:
课程编号:
课程序号:
题目:
学年学期:
课程名称:
课程编号:
课程序号:
MQTT – Class 2 - Group 12
Name:XianYue Xiao
tb_brand
我们需要在数据库中创建一个表 tb_brand
。假设我们使用的是 MySQL 数据库,表结构如下:
CREATE TABLE tb_brand (
id INT AUTO_INCREMENT PRIMARY KEY,
brand_name VARCHAR(255) NOT NULL,
company_name VARCHAR(255) NOT NULL,
ordered INT NOT NULL,
description TEXT,
status INT NOT NULL
);
public class Dog {
private int age;
private String color;
public Dog() {}
public Dog(int age, String color) {
this.age = age;
this.color = color;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
public void eat(String something) {
System.out.println(age + "岁的" + color + "颜色的狗两只前腿死死的抱住" + something + "猛吃");
}
public void lookHome() {
System.out.println("狗正在看家");
}
}
要求: 定义数组存储3部汽车对象。汽车的属性:品牌,价格,颜色。创建三个汽车对象,数据通过键盘录入而来,并把数据存入到数组当中。
import java.util.Scanner;
class Car {
private String brand;
private double price;
private String color;
// Constructors, getters, and setters
public Car(String brand, double price, String color) {
this.brand = brand;
this.price = price;
this.color = color;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getColor() {
return color;
}
public void setColor(String color) {
this.color = color;
}
@Override
public String toString() {
return "Car [brand=" + brand + ", price=" + price + ", color=" + color + "]";
}
}
class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Car[] cars = new Car[3];
for (int i = 0; i < cars.length; i++) {
System.out.println("Enter details for car " + (i + 1));
System.out.print("Brand: ");
String brand = scanner.nextLine();
System.out.print("Price: ");
double price = scanner.nextDouble();
System.out.print("Color: ");
scanner.nextLine(); // Consume newline
String color = scanner.nextLine();
cars[i] = new Car(brand, price, color);
}
System.out.println("Cars entered:");
for (Car car : cars) {
System.out.println(car);
}
}
}
老师强调的考点:
单链表的插入(基本语句)删除,头插尾插(有什么不同,各自的特点)。各个复杂度等。
双链表的插入删除(删除给定结点的前驱后继等等)
L = (D,R)
D = {ai | 1<= i <= n , n>0 , ai为ElemType类型}
R = {r}
r = {<ai,ai+1> | 1 <= i <= n-1}
G=(V,E)
V:顶点(数据元素)的有穷非空集合
E:边的有穷集合
有向图中:起始端点和终止端点;出边邻接点和入边邻接点
度:某个结点的子树的个数。树中所有结点的度的最大值称为树的度。
分支结点和叶子结点
路径和路径长度
孩子结点,双亲结点和兄弟结点
结点层次和树的高度
有序树和无序树
森林
假设度数为0,1,2,3…的结点有n0,n1,n2,n3…
个
则:n0+n1+n2+n3….=0 * n0 + 1 * n1 + 2 * n2 + 3 * n3….
题目1(选择):
下列关于java变量声明那个是错误的:
A. int x = 5;
B. double d = 3.14;
C. char grade = ‘C’;
D. String name = ‘我是小红’;
答案:D. String name = ‘我是小红’;(错误,应该使用双引号)
题目2(看代码说结果):
看代码说结果,不要去运行。
double money = 10.0;
money = money + 5;
money -= 2.5;
money = money + 10;
money = money - 3;
System.out.println(money);
以下是每道题目的参考答案:
int[] arr = {1, 2, 3, 4, 5, 6};
for (int i = 0; i < arr.length; i++) {
System.out.print(arr[i] + " ");
}