Screenshot

Program
RetailItem.java
/**
* Create a class to keep retail store items details
* @author deept
*
*/
public class RetailItem {
//Attributes
private String description;
private int unitsOnHand;
private double price;
//Constructor set values of attributes
public RetailItem(String desc,int units,double pr)
{
setDescription(desc);
setUnitsOnHand(units);
setPrice(pr);
}
//Mutators
public void setDescription(String description) {
this.description =
description;
}
public void setUnitsOnHand(int unitsOnHand) {
if(unitsOnHand<0) {
this.unitsOnHand
= 0;
}
else {
this.unitsOnHand
= unitsOnHand;
}
}
public void setPrice(double price) {
if(price<0) {
this.price=0;
}
else {
this.price=price;
}
}
//Accessors
public String getDescription() {
return description;
}
public int getUnitsOnHand() {
return unitsOnHand;
}
public double getPrice() {
return price;
}
//Method to purchase item from store
public void purchaseItem(int totalItemsToPurchase)
{
if(
totalItemsToPurchase<=unitsOnHand) {
unitsOnHand-=
totalItemsToPurchase;
System.out.printf("%-20s%.2f\n",description,totalItemsToPurchase*price);
}
else {
System.out.println("Item not enough to purchase!!!");
}
}
}
RetailItemDriver.java
/**
* Test class to check RetailItem class
* @author deept
*
*/
public class RetailItemDriver {
public static void main(String[] args) {
// Create 3 RetailItem
objects
RetailItem item1=new
RetailItem("Jacket",12,59.95);
RetailItem item2=new
RetailItem("Shoes",40,34.95);
RetailItem item3=new
RetailItem("Pants",20,24.95);
//Display initial details of
items
System.out.println("Description Units on
Hand Price");
System.out.printf("%-20s%-10d%.2f\n",item1.getDescription(),item1.getUnitsOnHand(),item1.getPrice());
System.out.printf("%-20s%-10d%.2f\n",item2.getDescription(),item2.getUnitsOnHand(),item2.getPrice());
System.out.printf("%-20s%-10d%.2f\n",item3.getDescription(),item3.getUnitsOnHand(),item3.getPrice());
//Purchase the following
items
System.out.println();
System.out.printf("%-20s%s\n","Description","Purchase Cost");
//Jacket 10
item1.purchaseItem(10);
//Shoes 20
item2.purchaseItem(20);
//Pants 5
item3.purchaseItem(5);
//Jacket 5
item1.purchaseItem(5);
//Shoes 10
item2.purchaseItem(10);
//Pants 3
item3.purchaseItem(3);
}
}
Output
Description Units on Hand Price
Jacket
12 59.95
Shoes
40 34.95
Pants
20 24.95
Description
Purchase Cost
Jacket
599.50
Shoes
699.00
Pants
124.75
Item not enough to purchase!!!
Shoes
349.50
Pants
74.85
Programming Assignment 6: Object Oriented Programming Due date: Check Syllabus and Canvas Objectives: After successfully completing...
4. RetailItem Class Write a class named RetailItem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the item. • unitsOnHand. The unitsOnHand field is an int variable that holds the number of units currently in inventory. • price. The price field is a double that holds the item’s retail price. Write a constructor that accepts arguments...
Write a Gui programming by using JavaFx menus, stage and screen
concepts to the RetailItem class,
Write a class named Retailltem that holds data about an item in a retail store. The class should have the following fields description: The description field is a String object that holds a brief description of the item . unitsOnHand: The unitsOnHand field is an int variable that holds the number of units currently in inventory Price: The price field is a double that...
USE C++. Just want to confirm is this right~? Write a class named RetailItem that holds data about an item in a retail store. The class should have the following member variables: description: A string that holds a brief description of the item. unitsOnHand: An int that holds thw number of units currently in inventory. price: A double that holds that item's retail price. Write the following functions: -appropriate mutator functions -appropriate accessor functions - a default constructor that sets:...
in java PART ONE ======================================= Below is the "RetailItem" class definition that we used in Chapter 6. Write a "CashRegister" class that leverages this "RetailItem" class which simulates the sale of a retail item. It should have a constructor that accepts a "RetailItem" object as an argument. The constructor should also accept an integer that represents the quantity of items being purchased. Your class should have these methods: getSubtotal: returns the subtotal of the sale, which is quantity times price....
*Python* INTRODUCTION: The goal of this programming assignment is to enable the student to practice object-oriented programming using classes to create objects. PROBLEM DEFINITION: Write a class named Employee that holds the following data about an employee in attributes: name, IDnumber, department, jobTitle The class should have 8 methods as follows: For each attribute, there should be a method that takes a parameter to be assigned to the attribute. This is known as a mutator method. For each...
in python Write a class named RetaiI_Item that holds data about an item in a retail store. The class should store the following data in attributes: • Item Number • Item Description • Units in Inventory • Price Create another class named Cash_Register that can be used with the Retail_Item class. The Cash_Register class should be able to internally keep a list of Retail_Item objects. The class should include the following methods: • A method named purchase_item that accepts a...
In this module you learned about Object-Oriented programming in C++ and how to combine this approach with the concepts covered in previous modules For this assignment you will write a class called Dog that has the following member variables: birthyear. An int that holds the dog’s birth year. breed. A string that holds the breed of dog. vaccines. A Boolean holding a yes/no value indicating whether the dog is currently on vaccinations. In addition, the class should have the following...
Week 6: Lab Overview TABLE OF CONTENTS Lab Overview Scenario/Summary Write a windows console application that holds data about an item in a retail store. Your class should be named RetailItem and should hold data about an item in a retail store. The class will have the following member variables. Description - string holding the description of the item, unitsOnHand - int that holds the number of units in inventory Price - double that holds the price of the item...
Purpose: The main goal of this assignment is to practice Object Oriented Programming by creating classes, writing methods, and creating inheritance type relationships. Task: Create a Java project using the IDE Write a program using Object Oriented Programming Plan a program where two classes inherit from a single class and theme it in a way that makes sense. Create a super class with a non-constructor method Create two sub classes with their own non-constructor methods and have them inherit from...
Programming Assignment 5: UML Diagram Objectives: After successfully completing this assignment, students will practice Object Oriented design by creating an UML diagram for a Java program. Program Statement: Bank System You were asked to create a simple UML diagram for a bank system. Each bank has a specific identification number, a name, and a location that needs to be stored. Tellers serve customers’ loans, checking and savings accounts. The bank must know each tellers’ name and identification number for record...