Студопедия

Главная страница Случайная страница

Разделы сайта

АвтомобилиАстрономияБиологияГеографияДом и садДругие языкиДругоеИнформатикаИсторияКультураЛитератураЛогикаМатематикаМедицинаМеталлургияМеханикаОбразованиеОхрана трудаПедагогикаПолитикаПравоПсихологияРелигияРиторикаСоциологияСпортСтроительствоТехнологияТуризмФизикаФилософияФинансыХимияЧерчениеЭкологияЭкономикаЭлектроника






  • Текст классов. public double Series;






    Класс “Tv”:

     

    public class TV {

    public String Firm;

    public double Series;

    public double Length;

    public double Width;

    public double Height;

    public double Weight;

     

    public TV(String Firm, double Series, double Length, double Width, double Height, double Weight) {

    this.Series = Series;

    this.Firm = Firm;

    this.Length = Length;

    this.Width = Width;

    this.Height = Height;

    this.Weight = Weight;

    }

     

    public boolean accord(Stand s1){

    if (((s1.getWidth() > Width) & (s1.getLength() > Length)) & (s1.getCarrying_Capacity() > = Weight)) {

    return true;

    }

     

    return false;

     

     

    }

     

    public String toString() {

    return " \n Телевизор: Фирма - " + Firm + " Серия - " + Series + " Длина - " + Length + " Ширина - " + Width + " Высота - " + Height + " Вес - " + Weight;

    }

    }

     

     

    Класс “Stand”:

    public class Stand {

    private double Length;

    private double Width;

    private double Carrying_Capacity;

    private String Material;

     

    public Stand(double Length, double Width, double Carrying_Capacity, String Material) {

    this.Length = Length;

    this.Width = Width;

    this.Carrying_Capacity = Carrying_Capacity;

    this.Material = Material;

    }

     

    public String getMaterial() {

    return Material;

    }

     

    public double getLength() {

    return Length;

    }

     

    public double getCarrying_Capacity() {

    return Carrying_Capacity;

    }

     

    public double getWidth() {

    return Width;

    }

     

    public void setMaterial(String Material) {

    this.Material = Material;

    }

     

     

    public void setLength(double Length) {

    this.Length = Length;

    }

     

     

    public void setWidth(double Width) {

    this.Width = Width;

    }

     

    public void setCarrying_Capacity(double Carrying_Capacity) {

    this.Carrying_Capacity = Carrying_Capacity;

    }

     

    public String toString(){

    return " Длина - " + Length + " Ширина - " + Width + " Грузоподъемность - " + Carrying_Capacity + " Материал - " + Material;

    }

     

    }

    Класс ' ObjDemoLab11':

    public class ObjDemoLab11 {

     

    public static void comparisonObj(TV f, Stand ff){

    if (f.accord(ff) == true){

    System.out.println(" \n" + " На полку можно поставить телевизор! ");

    System.out.println(" \n" + f.toString());

    }

    else System.out.println(" \n" + " На полку нельзя поставить телевизор! ");

    }

     

     

    public static void main(String[] args) {

    TV tv = new TV(" Samsung", 5858585, 42, 50, 30, 2.5);

    TV tv1 = new TV(" Toshiba", 14880420, 32, 38, 25, 4);

     

    Stand stand = new Stand(50, 60, 3, " Древесина");

     

     

    comparisonObj(tv, stand);

    comparisonObj(tv1, stand);

     

    System.out.printf(" \n" + " Дллина = %5.2f Ширина = %5.2f Грузоподъемность - %5.2f Материал - " + stand.getMaterial(), stand.getLength(), stand.getWidth(), stand.getCarrying_Capacity());

     

    tv.Firm = " Asus";

    tv.Series = 57585748;

    tv.Length = 80;

    tv.Height = 100;

    tv.Width = 80;

    tv.Weight = 7;

     

    stand.setWidth(90);

    stand.setMaterial(" Мрамор");

    stand.setCarrying_Capacity(10);

    stand.setLength(85);

     

    System.out.println(" \n" + tv.toString());

    System.out.println(" \n" + stand.toString());

    comparisonObj(tv, stand);

     

    }

     

     

    }

     






    © 2023 :: MyLektsii.ru :: Мои Лекции
    Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав.
    Копирование текстов разрешено только с указанием индексируемой ссылки на источник.