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 returning the average number of paintings per artist.
You should create a test class which creates 2 Art Gallery objects, then calls your set methods, get methods, toString and equals methods and average paintings per artist for the Art Gallery objects.
AS PER THE QUESTION GIVEN
CODE:
STORE CLASS:
public class Store {
private String name;
private String city;
public Store() {
super();
}
public Store(String name, String city) {
super();
this.name = name;
this.city = city;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
@Override
public String toString() {
return "Store [name=" + name + ",
city=" + city + "]";
}
@Override
public boolean equals(Object obj) {
// TODO Auto-generated method
stub
Store store=(Store) obj;
if(store.getCity().contentEquals(city) &&
store.getName().contentEquals(name)) {
return
true;
}else {
return
false;
}
}
}
ART GALLERY CLASS:
public class ArtGallery extends Store{
private int numberOfPaintinigsSold;
private int numberOfArtists;
public ArtGallery() {
super();
}
public ArtGallery(String name, String city, int
numberOfPaintinigsSold, int numberOfArtists) {
super(name, city);
this.numberOfPaintinigsSold =
numberOfPaintinigsSold;
this.numberOfArtists =
numberOfArtists;
}
public int getNumberOfPaintinigsSold() {
return
numberOfPaintinigsSold;
}
public void setNumberOfPaintinigsSold(int
numberOfPaintinigsSold) {
this.numberOfPaintinigsSold =
numberOfPaintinigsSold;
}
public int getNumberOfArtists() {
return numberOfArtists;
}
public void setNumberOfArtists(int numberOfArtists)
{
this.numberOfArtists =
numberOfArtists;
}
@Override
public String toString() {
return "ArtGallery
[numberOfPaintinigsSold=" + numberOfPaintinigsSold + ",
numberOfArtists=" + numberOfArtists
+ "]";
}
public float averagePaintingsPerArtist() {
return
((float)numberOfPaintinigsSold)/numberOfArtists;
}
}
MAIN CLASS:
import java.util.Scanner;
public class Driver {
public static void main(String[] args) {
Scanner scanner=new
Scanner(System.in);
//create first Art Gallery
object
ArtGallery gallery1=new
ArtGallery();
//take the input from user and set
the attributes of Art Gallery 1
System.out.println("Enter the name
of your Art Gallery 1: ");
gallery1.setName(scanner.nextLine());
System.out.println("Enter the city
of "+gallery1.getName()+" :");
gallery1.setCity(scanner.nextLine());
System.out.println("Enter the
number of paintings sold every year at "+gallery1.getName()+"
:");
gallery1.setNumberOfPaintinigsSold(scanner.nextInt());
System.out.println("Enter the
number of artists at "+gallery1.getName()+" :");
gallery1.setNumberOfArtists(scanner.nextInt());
scanner.nextLine(); //skip the next
input
//create first Art Gallery
object
ArtGallery gallery2=new
ArtGallery();
//take the input from user and set
the attributes of Art Gallery 1
System.out.println("Enter the name
of your Art Gallery 2: ");
gallery2.setName(scanner.nextLine());
System.out.println("Enter the city
of "+gallery2.getName()+" :");
gallery2.setCity(scanner.nextLine());
System.out.println("Enter the
number of paintings sold every year at "+gallery2.getName()+"
:");
gallery2.setNumberOfPaintinigsSold(scanner.nextInt());
System.out.println("Enter the
number of artists at "+gallery2.getName()+" :");
gallery2.setNumberOfArtists(scanner.nextInt());
System.out.println("Average number
of paintings per Artist at "+gallery1.getName()+" is :-
"+gallery1.averagePaintingsPerArtist());
System.out.println("Average number
of paintings per Artist at "+gallery2.getName()+" is :-
"+gallery2.averagePaintingsPerArtist());
}
}
IF YOU HAVE ANY DOUBTS COMMENT BELOW
THANKS
IN JAVA Write a class Store which includes the attributes: store name, city. Write another class...
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...
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...
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 encapsulating a music store, which inherits from Store. A music store has the following additional attributes: the number of titles it offers and its address. Code the constructor and the toString method of the new class. You also need to include a client class (with the main method) to test your code.
In JAVA, please In this module, you will combine your knowledge of class objects, inheritance and linked lists. You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. Game is the parent class with the following attributes: 1. description - which is a string 2. write the constructor, accessor, mutator and toString methods. Trivia is the subclass of Game with the additional attributes: 1. trivia game id - integer 2. ultimate prize money...
Here is a sample run of the tester program: Make sure your program follows the Java Coding Guidelines. Consider the following class: /** * A store superclass with a Name and Sales Tax Rate */ public class Store { public final double SALES_TAX_RATE = 0.06; private String name; /** * Constructor to create a new store * @param newName */ public Store(String newName) { name = newName; } ...
You will need to first create an object class encapsulating a Trivia Game which INHERITS from Game. Game is the parent class with the following attributes: description - which is a string write the constructor, accessor, mutator and toString methods. Trivia is the subclass of Game with the additional attributes: 1. trivia game id - integer 2. ultimate prize money - double 3. number of questions that must be answered to win - integer. 4. write the accessor, mutator, constructor,...
Write a class encapsulating the concept of a television set, assuming a television set has the following attributes: a brand and a price. include a constructor, the accessors and mutators, and methods to string and equals. Write a client class to test all the methods in your class.
Write a class that encapsulates the concept of a baseball player with the important attributes (name, position, hits, at bats, batting average). The class will have the following methods: Two constructors (a default and a constructor with all parameters) Accessors, mutators, toString, and equals methods The batting average property will not have a public setter, it will be updated any time the hits and/or at bats is set. The getter will round to three digits (.315 or .276, etc.) All...
How to solve this problem? Consider the following class : public class Store Public final double SALES TAX_RATE = 0.063B private String name; public Store(String newName) setName ( newName); public String getName () { return name; public void setName (String newName) { name = newName; public String toString() return "name: “ + name; Write a class encapsulating a web store, which inherits from Store. A web store has the following additional attributes: an Internet Address and the programming language in...