package Abcd;
import java.util.Scanner;
class Mobile{
private int num;
private String brand;
private double amount;
private double price;
private double all;
public Mobile() {
}
public Mobile(int num,String brand,double amount,double price,double all) {
this.num=num;
this.brand=brand;
this.amount=amount;
this.price=price;
this.all=all;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public double getAll() {
return all;
}
public void setAll(double all) {
this.all = all;
}
public void printMobile() {
System.out.println(this.num+" "+this.brand+" "+this.amount+" "+this.price+" "+this.all);
}
public static void printMb() {
System.out.println(" 手机信息 ");
System.out.println("序号 手机品牌 数量 单价 小计");
}
public static void printMu() {
System.out.println("**********手机销售管理**********");
System.out.println("----1.显示---------2.按单价排序--");
System.out.println("----3.查询---------0.退出--");
System.out.println("请输入功能代码(0~3)");
}
}
public class Demo13 {
public static void main(String[]args) {
Mobile phone[]=new Mobile[4];
phone[0]=new Mobile(1,"华为",10,3500,35000);
phone[1]=new Mobile(2,"小米",20,2100,42000);
phone[2]=new Mobile(3,"VIVO",17,2800,47600);
phone[3]=new Mobile(4,"OPPO",8,1355,10840);
Mobile.printMu();
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
switch(a) {
case(1):{
Mobile.printMb();
for(int i=0;i<phone.length;i++) {
phone[i].printMobile();
}
break;
}
case(2):{
Mobile m=new Mobile();
for(int j=1;j<4;j++)
for(int k=0;k<4;k++)
{
if(phone[j].getPrice()<phone[k].getPrice())
{
m=phone[k];
phone[k]=phone[j];
phone[j]=m;
}
}
for(int i=0;i<phone.length;i++) {
phone[i].printMobile();
}
break;
}
case(3):{
Scanner scan1=new Scanner(System.in);
System.out.println("请输入需要查寻手机的名称:");
String str=scan1.next();
for(int i=0;i<4;i++) {
if(phone[i].getBrand().equals(str))
phone[i].printMobile();
}
break;
}
default:{
System.exit(0);
break;
}
}
}
}