Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Java] I'm totally lost help me please Here's the problem: Implement a subclass of Product called Painting. A Painting has a String instance variable, artist,

[Java] I'm totally lost help me please

Here's the problem:

Implement a subclass of Product called Painting. A Painting has a String instance variable, artist, in addition to description and price. These paintings are framed prints not originals.

Provide the instance variable and methods

public String getArtist()

public boolean sameAuthor( Painting other) returns true if the paintings have the same author. Otherwise false (updated Apr 1. You will have to use sameAuthor even though that does not make good sense for a painting. I make a mistake in the implementation)

public String getDescription() returns the description of the Painting then a space and the Artist's name

Provide Javadoc. Use @Override for the overridden getDescription method

Use the following files:

PaintingTester.java

 public class PaintingTester { public static void main(String[] args) { //be sure Painting is a subclass of Product Product product = new Painting("The Starry Night", 95.0, "Van Gogh"); //instantiate some Paintings Painting lilies = new Painting("The Water Lily Pond", 85.0, "Monet"); Painting bridge = new Painting("The Japanese Footbridge", 120.0, "Monet"); Painting girl = new Painting("Girl with a Hoop", 100, "Renoir"); Painting child = new Painting("Child with a Dove", 150.0, "Picasso"); Painting starry = (Painting)product; //Get a Painting reference to the Painting System.out.println(lilies.sameAuthor(bridge)); System.out.println("Expected: true"); System.out.println(girl.sameAuthor(child)); System.out.println("Expected: false"); System.out.println(starry.getDescription()); System.out.println("Expected: The Starry Night Van Gogh"); System.out.println(girl.getDescription()); System.out.println("Expected: Girl with a Hoop Renoir"); System.out.println(lilies.getPrice()); System.out.println("Expected: 85.0"); System.out.println("Artist: " + starry.getArtist()); System.out.println("Expected: Van Gogh"); } } 

Product.java

/** * Models a Product that can increase and decrease in price */ public class Product { private double price; private String description; /** * Constructs a Product with a price and a description * @param thePrice the price of this Product * @param theDescription - the description of this product */ public Product(String theDescription, double thePrice) { price = thePrice; description = theDescription; } /** * Gets the price * @return the price of this Product object */ public double getPrice() { return price; } /** * Gets the description * @return the description of the Product object */ public String getDescription() { return description; } /** * Reduces the price of this product by the give percentage * @param percent the percentage to reduce the priice by */ public void reducePrice(double percent) { double reduction = price * percent / 100; price = price - reduction; } /** * Increases the price by the given percent * @param percent the percent to increase the price by */ public void increasePrice(double percent) { double increase = price * percent / 100; price = price + increase; } } 

Here's my code;

import java.util.Arrays; public class Painting extends Product { private String artist; public Painting(String description, double price, String theArtist) { super(description, price); artist = theArtist; } public String getArtist() { return artist; } public boolean sameAuthor() { if(getArtist().equals(Product product)) { } } @Override public String getDescription() { String str = super.getDescription(); return str + " " + artist; } }

I'm not sure how to implement the sameAuthor method.

Please check your code using the link below. It has to exact same as the tester.

http://www.codecheck.it/files/16112801582mmmnphfjxw6xc3wokqnhiuhm

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

Why is employee referral so important in the recruitment process?

Answered: 1 week ago

Question

Design small DMZ network using VLAN

Answered: 1 week ago

Question

HOW IS MARKETING CHANGING WITH ARTIFITIAL INTELIGENCE

Answered: 1 week ago

Question

Different types of Grading?

Answered: 1 week ago

Question

Explain the functions of financial management.

Answered: 1 week ago

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

=+What is the most that you should pay to complete development?

Answered: 1 week ago

Question

=+development and make the product, should you go ahead and do so?

Answered: 1 week ago