特征:品牌
售价
分辨率
行为:渲染图形
Ati 类型独立显卡类:
特征:品牌
售价
分辨率
行为:渲染图形
package com.qf.work;
class Computer{
private VideoCard videoCard;
private String brand;
private double price;
public Computer() {
}
public Computer(VideoCard videoCard, String brand, double price) {
this.videoCard = videoCard;
this.brand = brand;
this.price = price;
}
public VideoCard getVideoCard() {
《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》
【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享
return videoCard;
}
public void setVideoCard(VideoCard videoCard) {
this.videoCard = videoCard;
}
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;
}
@Override
public String toString() {
return “电脑配置:” +
“(显卡类型:” + videoCard +’\t’+
“品牌:” + brand + ‘\t’ +
“价格:” + price;
}
public void runProgram(){
System.out.println(“使用”+toString()+“运行程序”);
}
public void runGame(){
System.out.println(“使用”+toString()+“运行游戏”);
}
public void playVideo(){
System.out.println(“使用”+toString()+“播放视频”);
}
}
class VideoCard{
private String brand;
private double price;
private String resolution;
public VideoCard() {
}
public VideoCard(String brand, double price, String resolution) {
this.brand = brand;
this.price = price;
this.resolution = resolution;
}
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 getResolution() {
return resolution;
}
public void setResolution(String resolution) {
this.resolution = resolution;
}
@Override
public String toString() {
return “品牌:” + brand +’\t’+
“价格:” + price +’\t’+
“分辨率:” + resolution+’)’;
}
public void renderDraw(){
System.out.println(“渲染图形”);
}
}
class Geforce extends VideoCard{
public Geforce() {
}
public Geforce(String brand, double price, String resolution) {
super(brand, price, resolution);
}
@Override
public String toString() {
return super.toString();
}
}
class Ati extends VideoCard{
public Ati() {
}
public Ati(String brand, double price, String resolution) {
super(brand, price, resolution);
}
@Override
public String toString() {
return super.toString();
}
}
class Programmer{
private String name;
private Computer computer;
public Programmer() {
}
public Programmer(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Computer getComputer() {
return computer;
}
public void setComputer(Computer computer) {
this.computer = computer;
}
@Override
public String toString() {
return “Programmer{” +
“name=’” + name + ‘’’ +
“, computer=” + computer +
‘}’;
}
public void buyComputer(Computer computer){
this.computer=computer;
}