Television.java:
public class Television {
private String brand;
private double price;
public Television() {
}
public Television(String brand, double price)
{
this.brand = brand;
this.price = price;
}
public String getBrand() {
return brand;
}
public double getPrice() {
return price;
}
public void setBrand(String brand) {
this.brand = brand;
}
public void setPrice(double price) {
this.price = price;
}
public String toString() {
return "Brand Name: "+getBrand()+"
Price: "+getPrice();
}
public boolean equals(Television television2)
{
if(getBrand().equals(television2.getBrand()) &&
getPrice()==television2.getPrice()) {
return
true;
} else{
return
false;
}
}
}
TelevisionTest.java:
import java.util.Scanner;
public class TelevisionTest {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
String brand;
double price;
System.out.println("Enter
Television1 Name:");
brand = sc.next();
System.out.println("Enter
Television1 Price:");
price = sc.nextDouble();
Television television1 = new
Television(brand, price);
System.out.println("Enter
Television2 Name:");
brand = sc.next();
System.out.println("Enter
Television2 Price:");
price = sc.nextDouble();
System.out.println("--------------------------");
System.out.println("Television1
Details are:");
System.out.println("getBrand():
"+television1.getBrand());
System.out.println("getPrice():
"+television1.getPrice());
System.out.println("toString()
method result: "+television1);
System.out.println("--------------------------");
System.out.println("Television2
Details are:");
System.out.println("getBrand():
"+television2.getBrand());
System.out.println("getPrice():
"+television2.getPrice());
System.out.println("toString() method result: "+television2);
System.out.println("--------------------------");
System.out.println("Checking equals
method");
if(television1.equals(television2))
{
System.out.println("Both televisions are equals");
} else {
System.out.println("Both televisions are not equals");
}
}
}
OUTPUT:
![Markers E Properties | Servers膼Data Source Explorer lb Snippets Console <terminated> TelevisionTest [Java Application] C:APro](http://img.homeworklib.com/questions/06780240-6503-11eb-b6b3-87f47f813c49.png?x-oss-process=image/resize,w_560)
Write a class encapsulating the concept of a television set, assuming a television set has the...
write a class encapsulating the concept of a student assuming
that the student has the following attributes the name of student
the average of the student the
rite a class encapsulating the concept of a Student, assuming that the Student has the following attributes: the name of the student, the average of the student, and the student's GPA. Include a default constructor, an overloaded constructor, the accessors and mutators, and methods, toString() and equals(). Also include a method returning the...
Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method returning the...
Write a class encapsulating the concept of a vendor, if a vendor has the following attributes: company name, id, array of quarterly purchase order totals (4 double elements). Include a constructor, accessor, mutator, and toString methods. Also code the following methods: one returning the total purchase orders (total all array elements) and a method to modify an array element (change the value of an array element). Write a client class to create 2 vendor objects and test all your methods.
[CODE] Write a class encapsulating the concept of a house, assuming a house has the following attributes: value (in dollars), a city location, and number of bedrooms. Your class name should be “House” and your code should be in a file called “House.java”. You will need to create this file. In this class, include: Private instance variables for the previously-mentioned attributes A default constructor An overloaded constructor Accessor and mutator methods (i.e., get and set methods) The toString method The...
IN JAVA Write a class Store which includes the attributes: store name, city. Write another class encapsulating an Art Gallery, which inherits from Store. An Art Gallery has the following additional attributes: how many paintings are sold every year and the number of artists submitting artwork. Code the constructor, accessors, mutators, toString and equals method of the super class Store. Code the constructor, accessors and mutators for the subclass Art Gallery. In the Art Gallery class, also code a method...
In Java, Write a class encapsulating a restaurant,which inherits from Store. A restaurant has the following additional attributes: how many people are served every year and the average price per person. code the constructor, accessors, mutators, toString and equals method of the new subclass; also code a method returning the average taxes per year. You also need to include a client class to test your code for both the parent class and the subclass. Code for Store below(Super class aka...
Using Java Write a class encapsulating the concept of student grades (50 elements) on a test, assuming student grades are composed of a list of integers between 0 and 100. Write the following methods: A constructor with just one parameter, the number of students; all grades can be randomly generated Accessor, mutator, toString, and equals methods A method returning the highest grade A method returning the average grade A method returning the lowest grade Write a client class to test...
Hello. I need help writing the following Java Program. Thank you Develop a class encapsulating the concept of a college course, assuming that a course has following attributers: code (for instance COSC1337), a description, and a number of credits (for instance 3). Include a constructor, the accessors, mutators and methods ‘toString’, ‘equals’, and ‘finalize’. Write a client class to test the behavior of the class and its methods. The outline of the class is given as follows: public class Course...
Write a class encapsulating the concept of daily temperatures for a week with a single dimensional array of temperatures. Write the following methods: • A constructor accepting an array of seven temperatures as a parameter. • Accessor, mutator, toString() and equals() methods • A method returning how many temperatures were below freezing. • A method returning an array of temperatures above 100 degrees. • A method returning the largest change in temperature between any two consecutive days. • A method...
Create the following program in java please Write a class Store which includes the attributes: store name and sales tax rate. Write another class encapsulating a Book Store, which inherits from Store. A Book Store has the following additional attributes: how many books are sold every year and the average price per book. Code the constructor, accessors, mutators, toString and equals method of the super class Store and the subclass Book Store; In the Book Store class, also code a...