1、类图 随意写个类 然后new model 选个model新建 然后直接把写好的类拖进model 自动生成类图
2、领养宠物并输出宠物信息
package com.opp.unit3.demo8;
/**
* Created by 渣渣飞 on 2018/6/11 20:12
* 星期一
* FDF
*/
public class Dog {
public String name;
public int age;
public String brand;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getBrand() {
return brand;
}
public void setBrand(String brand) {
this.brand = brand;
}
public Dog() {
name="狗";
age=2;
brand="傻狗";
}
public void showInfo() {
System.out.println("名字" + name +"年龄"+age+"种类"+brand);
}
}
package com.opp.unit3.demo8;
/**
* Created by 渣渣飞 on 2018/6/11 20:12
* 星期一
* FDF
*/
public class Test {
public static void main(String[] args) {
Dog dog=null;
dog=new Dog();
dog.showInfo();
}
}
package com.opp.unit3.pratice;
/**
* Created by 渣渣飞 on 2018/6/11 20:52
* 星期一
* FDF
*/
public class Student {
private String name;
private int age;
private String grender;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
if (age > 16) {
this.age = age;
} else {
System.out.println("输入错误!");
}
}
public String getGrender() {
return grender;
}
public void setGrender(String grender) {
this.grender = grender;
}
public void show() {
System.out.println("姓名:" + name + "年龄" + age + "性别" + grender);
}
}
package com.opp.unit3.pratice;
import java.util.Scanner;
/**
* Created by 渣渣飞 on 2018/6/11 21:03
* 星期一
* FDF
*/
public class Test {
public static void main(String[] args) {
Student stu=null;
stu=new Student();
Scanner scanner=new Scanner(System.in);
System.out.println("请输入姓名:");
String name=scanner.next();
stu.setName(name);
System.out.println("请输入年龄:");
int age=scanner.nextInt();
stu.setAge(age);
System.out.println("请输入性别:");
String grender=scanner.next();
stu.setGrender(grender);
stu.show();
}
}
package com.opp.unit4.demo1;
/**
* Created by 渣渣飞 on 2018/6/12 21:09
* 星期二
* FDF
*/
public abstract class Car {
/**
* 无参方法赋值!
*/
protected static String number;
protected static String brade;
public Car() {
number = "AU8769";
brade = "大奔";
}
/**
* 带参方法
*
* @param number
* @param brade
*/
public Car(String number, String brade) {
this.number = number;
this.brade = brade;
}
public double pay(int days,int type){
return 0;
}
}
package com.opp.unit4.demo1;
import java.util.Random;
import java.util.Scanner;
/**
* Created by 渣渣飞 on 2018/6/12 21:07
* 星期二
* FDF
*/
public class MyMain {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
SaloonCar saloonCar= new SaloonCar();
PassengerCar passengerCar = new PassengerCar();
Random random = new Random();
int randomNum=random.nextInt(1000);
System.out.println("欢迎来到汽车租赁");
/**
* 天数
* 类型
*
*/
System.out.println("请输入您要租赁的天数");
int day=scanner.nextInt();
System.out.println("请输入要租赁的汽车类型(1,轿车 2,客车)");
int che = scanner.nextInt();
if (che == 1) {
System.out.println("请输入要租赁汽车品牌(1,宝马 2,别克)");
int xin = scanner.nextInt();
if (xin == 1) {
System.out.println("请输入轿车的型号(1,商务舱GL8 2,林荫大道)");
int xinhao = scanner.nextInt();
System.out.println("您好,分配给您的汽车牌号是:京KU" + randomNum);
double money = saloonCar.pay(day, che); // 得到费用
System.out.println("顾客你好!你需要支付的租赁金额为:" + money);
}
if (xin == 2) {
System.out.println("请输入轿车的型号(1,商务舱GL8 2,林荫大道)");
int xinhao = scanner.nextInt();
System.out.println("您好,分配给您的汽车牌号是:鲁LD" + randomNum);
double money = saloonCar.pay(day, che); // 得到费用
System.out.println("顾客你好!你需要支付的租赁金额为:" + money);
}
}
if (che == 2) {
System.out.println("请输入要租赁客车的品牌(1.金杯 2.金龙)");
int pin = scanner.nextInt();
System.out.println("请输入客车的座位数");
int ke = scanner.nextInt();
System.out.println("您好,分配给您的汽车牌号是:京KU" + randomNum);
double money = passengerCar.pay(day, che); // 得到费用
System.out.println("顾客你好!你需要支付的租赁金额为:" + money);
}
}
}
package com.opp.unit4.demo1;
/**
* Created by 渣渣飞 on 2018/6/12 21:09
* 星期二
* FDF
*/
public class PassengerCar extends Car {
private int seatCount;
/**
* 无参的构造
*/
public PassengerCar() {
seatCount = 23;
}
public PassengerCar(int seatCount) {
super(number, brade);
this.seatCount = seatCount;
}
public int gettype() {
return seatCount;
}
public double pay(int days, int type) {
double money = 0;
if (type > 16) {
money = days * 1000;
} else {
money = days * 500;
}
return money;
}
}
package com.opp.unit4.demo1;
/**
* Created by 渣渣飞 on 2018/6/12 21:10
* 星期二
* FDF
*/
public class SaloonCar extends Car {
private String type;
/**
* 无参构造
*/
public SaloonCar() {
type = "商务舱";
}
public SaloonCar(String type) {
super(number, brade);
this.type = type;
}
public String getType() {
return type;
}
/**
* 租金
*/
public double pay(int days, int type) {
double money = 0;
switch (type) {
case 1:
money = days * 500;
break;
case 2:
money = days * 600;
break;
case 3:
money = days * 300;
break;
default:
System.out.println("输入错误");
}
return money;
}
}