Question: Convert the following to swift code import java.text. Number Format; public class Item { private String name; private double price; private int quantity; // Create
Convert the following to swift code

import java.text. Number Format; public class Item { private String name; private double price; private int quantity; // Create a new item with the given attributes. name public Item (String itemName, double itemPrice, int numPurchased) { itemName; price itemPrice; quantity numPurchased; } // Return a string with the information about the item // public String toString() { Number Format fmt = Number Format.getCurrency Instance(); return (name + "\t" + fmt.format(price) + "\t" + quantity + "\t" + fmt.format(price * quantity)); } // // Returns the unit price of the item public double getPrice() { return price; } Returns the name of the item public String getName() { return name; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
