Results 1 to 13 of 13
  1. #1
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default InventoryPart6 Error

    i have an error can someone please help me with this......

    C:\Java Test>javac InventoryPart6.java
    InventoryPart6.java:370: error: constructor Supplier in class Supplier cannot be
    applied to given types;
    Supplier supplier = new Supplier();
    ^
    required: int,String,int,double,String
    found: no arguments
    reason: actual and formal argument lists differ in length
    1 error

    C:\Java Test>
    Java Code:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.text.DecimalFormat;
    import java.util.ArrayList;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    
    @SuppressWarnings("serial")
    public class InventoryPart6 extends JFrame implements ActionListener {
    	private static DecimalFormat currency = new DecimalFormat("$#,##0.00");
    
    	private Logo logo;
    	private JTextArea itemData;
    	private JButton firstItem;
    	private JButton previousItem;
    	private JButton nextItem;
    	private JButton lastItem;
    	private JButton addItem;
    	private JButton removeItem;
    	private JButton modifyItem;
    	private JButton saveItems;
    	private JButton searchItem;
    
    	private ArrayList<Supplier> products;
    	private int current = 0;
    
    	public static void main(String[] args) {
    		new InventoryPart6();
    	}
    
    	public InventoryPart6() {
    		products = new ArrayList<Supplier>();
    
    		
    		products.add(new Supplier(500, "Latitude", 10, 800, "Dell"));
    		products.add(new Supplier(200, "Vostro", 20, 650, "Dell"));
    		products.add(new Supplier(300, "Pavilion", 15, 890, "HP"));
    		products.add(new Supplier(350, "Vaio", 10, 1200, "Sony"));
    		products.add(new Supplier(400, "MacBook", 80, 1500, "Apple"));
    
    		
    		sortArray();
    
    		configureGUI();
    	}
    
    	private void configureGUI() {
    		setTitle("InventoryPart 6");
    		setDefaultCloseOperation(EXIT_ON_CLOSE);
    		setSize(700, 360);
    		setLocationRelativeTo(null);
    
    		logo = new Logo();
    		logo.setPreferredSize(new Dimension(getWidth(), 60));
    		logo.setFont(new Font("Courier New", Font.BOLD, 28));
    		itemData = new JTextArea(12, 40);
    		firstItem = new JButton("First");
    		firstItem.addActionListener(this);
    		previousItem = new JButton("Previous");
    		previousItem.addActionListener(this);
    		nextItem = new JButton("Next");
    		nextItem.addActionListener(this);
    		lastItem = new JButton("Last");
    		lastItem.addActionListener(this);
    		addItem = new JButton("Add");
    		addItem.addActionListener(this);
    		removeItem = new JButton("Remove");
    		removeItem.addActionListener(this);
    		modifyItem = new JButton("Modify");
    		modifyItem.addActionListener(this);
    		saveItems = new JButton("Save");
    		saveItems.addActionListener(this);
    		searchItem = new JButton("Search");
    		searchItem.addActionListener(this);
    
    		setLayout(new BorderLayout());
    
    		JPanel south = new JPanel(new FlowLayout());
    		south.add(firstItem);
    		south.add(previousItem);
    		south.add(nextItem);
    		south.add(lastItem);
    		south.add(addItem);
    		south.add(modifyItem);
    		south.add(removeItem);
    		south.add(searchItem);
    		south.add(saveItems);
    
    		add(logo, BorderLayout.NORTH);
    		add(new JScrollPane(itemData), BorderLayout.CENTER);
    		add(south, BorderLayout.SOUTH);
    
    		setVisible(true);
    		displayItem();
    	}
    
    	
    	public double calculateInventory() {
    		double value = 0;
    		for (int i = 0; i < products.size(); i++) {
    			value += products.get(i).calculateInventory();
    		}
    		return value;
    	}
    
    	
    	public void sortArray() {
    		int n = products.size(); 
    		boolean swapped;
    		do {
    			swapped = false;
    			for (int i = 0; i < n - 1; i++) {
    				Supplier p1 = products.get(i);
    				String name1 = p1.getProductName();
    				Supplier p2 = products.get(i + 1);
    				String name2 = p2.getProductName();
    				if (name1.compareToIgnoreCase(name2) > 0) {
    					
    					Supplier temp = p1;
    					products.set(i, p2);
    					products.set(i + 1, temp);
    					swapped = true;
    				}
    			}
    			n = n - 1;
    		} while (swapped);
    	}
    
    	@Override
    	public void actionPerformed(ActionEvent e) {
    
    		if (firstItem.equals(e.getSource())) {
    			displayFirstItem();
    
    		} else if (previousItem.equals(e.getSource())) {
    			displayPreviousItem();
    
    		} else if (nextItem.equals(e.getSource())) {
    			displayNextItem();
    
    		} else if (lastItem.equals(e.getSource())) {
    			displayLastItem();
    
    		} else if (addItem.equals(e.getSource())) {
    			addItem();
    
    		} else if (removeItem.equals(e.getSource())) {
    			removeItem();
    
    		} else if (modifyItem.equals(e.getSource())) {
    			modifyItem();
    
    		} else if (searchItem.equals(e.getSource())) {
    			seachItem();
    
    		} else if (saveItems.equals(e.getSource())) {
    			saveItems();
    
    		}
    	}
    
    	private void saveItems() {
    		File file;
    
    		file = new File("c:\\data");
    		if (!file.exists()) {
    			file.mkdir();
    		}
    
    		file = new File("c:\\data\\inventory.dat");
    		if (file.exists()) {
    			file.delete();
    		}
    
    		try {
    			file.createNewFile();
    		} catch (IOException ioe) {
    			JOptionPane.showMessageDialog(null,
    					"Failed to create the Inventory file.");
    			return;
    		}
    
    		BufferedWriter writer;
    		try {
    			writer = new BufferedWriter(new FileWriter(file));
    		} catch (IOException e) {
    			JOptionPane.showMessageDialog(null,
    					"Could not create the inventory file.");
    			return;
    		}
    
    		String line;
    		for (int i = 0; i < products.size(); i++) {
    			Supplier product = products.get(i);
    
    			line = product.getProductName() + "\t";
    			line += product.getItemNumber() + "\t";
    			line += product.getPrice() + "\t";
    			line += product.getUnitsInStock() + "\t";
    			line += product.getSupplierName() + "\n";
    
    			try {
    				writer.write(line);
    			} catch (IOException e) {
    				JOptionPane.showMessageDialog(null,
    						"Could not write in the inventory file.");
    			}
    		}
    
    		try {
    			writer.close();
    		} catch (IOException e) {
    			JOptionPane.showMessageDialog(null,
    					"Could not close the inventory file.");
    		}
    
    		JOptionPane.showMessageDialog(null, "File Saved.");
    	}
    
    	private int findByProductName(String name) {
    		int index = -1;
    		for (int i = 0; i < products.size(); i++) {
    			Supplier product = products.get(i);
    			if (product.getProductName().equalsIgnoreCase(name)) {
    				index = i;
    				break;
    			}
    		}
    		return index;
    	}
    
    	private void seachItem() {
    		String productName = JOptionPane
    				.showInputDialog("Enter the product name");
    
    		if (productName != null) {
    			
    			int index = findByProductName(productName);
    
    			if (index != -1) {
    				current = index;
    				displayItem();
    			} else {
    				JOptionPane.showMessageDialog(null, "Product: " + productName
    						+ " does not exist.");
    			}
    		}
    
    	}
    
    	private void modifyItem() {
    		if (current != -1) {
    			
    			String name = promptString("Enter the product name");
    			int units = promptInteger("Enter the number of units");
    			double price = promptDouble("Enter product price");
    			String supplierName = promptString("Enter the supplier name");
    
    			
    			Supplier supplier = products.get(current);
    			supplier.setName(name);
    			supplier.setUnitsInStock(units);
    			supplier.setPrice(price);
    			supplier.setSupplierName(supplierName);
    
    			
    			displayItem();
    		}
    	}
    
    	private void displayLastItem() {
    		
    		current = products.size() - 1;
    		displayItem();
    	}
    
    	private void displayNextItem() {
    
    		current++;
    		if (current > products.size() - 1) {
    			
    			current = 0;
    		}
    		displayItem();
    	}
    
    	private void displayPreviousItem() {
    		
    		current--;
    		if (current < 0) {
    		
    			current = products.size() - 1;
    		}
    		displayItem();
    	}
    
    	private void displayFirstItem() {
    		
    		current = 0;
    		displayItem();
    	}
    
    	private String prompt(String message) {
    		return JOptionPane.showInputDialog(this, message);
    	}
    
    	private String promptString(String message) {
    		String data = null;
    		do {
    			data = prompt(message);
    		} while (data == null);
    		return data;
    	}
    
    	private int promptInteger(String message) {
    		int data = 0;
    		boolean isValid = false;
    		do {
    			String dataString = prompt(message);
    			if (dataString != null) {
    				try {
    					data = Integer.parseInt(dataString);
    					isValid = true;
    				} catch (Exception e) {
    					isValid = false;
    				}
    			}
    		} while (!isValid);
    		return data;
    	}
    
    	private double promptDouble(String message) {
    		double data = 0;
    		boolean isValid = false;
    		do {
    			String dataString = prompt(message);
    			if (dataString != null) {
    				try {
    					data = Double.parseDouble(dataString);
    					isValid = true;
    				} catch (Exception e) {
    					isValid = false;
    				}
    			}
    		} while (!isValid);
    		return data;
    	}
    
    	private void addItem() {
    		
    		String name = promptString("Enter the product name");
    		int units = promptInteger("Enter the number of units");
    		double price = promptDouble("Enter product price");
    		String supplierName = promptString("Enter the product supplier");
    
    		
    		Supplier supplier = new Supplier();
    		supplier.setName(name);
    		if (products.size() > 0) {
    			Supplier lastProduct = products.get(products.size() - 1);
    			supplier.setItemNumber(lastProduct.getItemNumber() + 1);
    		} else {
    			supplier.setItemNumber(1);
    		}
    		supplier.setPrice(price);
    		supplier.setUnitsInStock(units);
    		supplier.setSupplierName(supplierName);
    		products.add(supplier);
    
    		
    		displayLastItem();
    	}
    
    	private void removeItem() {
    		if (products.size() > 0) {
    			products.remove(current);
    			displayLastItem();
    		}
    	}
    
    	private void displayItem() {
    		if (current >= 0) {
    			Supplier supplier = products.get(current);
    			StringBuilder sb = new StringBuilder();
    
    			sb.append("Item Number: " + supplier.getItemNumber() + "\n");
    			sb.append("Product Name: " + supplier.getProductName() + "\n");
    			sb.append("Units In Stock: " + supplier.getUnitsInStock() + "\n");
    			sb.append("Unit Price: " + currency.format(supplier.getPrice())
    					+ "\n");
    			sb.append("Supplier Name: " + supplier.getSupplierName() + "\n");
    			sb.append("Inventory  Value: "
    					+ currency.format(supplier.calculateInventory()) + "\n");
    			sb.append("Restock Fee: "
    					+ currency.format(supplier.calculateRestockFee()) + "\n");
    
    			sb.append("\n\nValue of the entire inventory: "
    					+ currency.format(calculateInventory()));
    
    			itemData.setText(sb.toString());
    		} else {
    			itemData.setText(null);
    		}
    	}
    }

  2. #2
    Junky's Avatar
    Junky is online now Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: InventoryPart6 Error

    Did you read the error message? It is quite obviuos what is wrong. You call the Supplier constructor and pass no parameters and yet what parameters does the Supplier constructor expect? Hint: the error message told you.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: InventoryPart6 Error

    The error message is telling you exactly what is wrong. Let's try to interpret this, OK?

    what is your take or guess on what this means:

    C:\Java Test>javac InventoryPart6.java
    InventoryPart6.java:370: error: constructor Supplier in class Supplier cannot be
    applied to given types;
    Supplier supplier = new Supplier();
    ^
    required: int,String,int,double,String
    found: no arguments
    reason: actual and formal argument lists differ in length
    1 error

  4. #4
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: InventoryPart6 Error

    i know what it means but i try changing it and it still wont work here is the code now. I am sorry guy i am pretty dam dumb at this i am so glad this is my last week in this class i just need to get this done so i can pass it please help me.
    Java Code:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.Font;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.io.BufferedWriter;
    import java.io.File;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.text.DecimalFormat;
    import java.util.ArrayList;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    
    @SuppressWarnings("serial")
    public class InventoryPart6 extends JFrame implements ActionListener {
    	private static DecimalFormat currency = new DecimalFormat("$#,##0.00");
    
    	private Logo logo;
    	private JTextArea itemData;
    	private JButton firstItem;
    	private JButton previousItem;
    	private JButton nextItem;
    	private JButton lastItem;
    	private JButton addItem;
    	private JButton removeItem;
    	private JButton modifyItem;
    	private JButton saveItems;
    	private JButton searchItem;
    
    	private ArrayList<Supplier> products;
    	private int current = 0;
    
    	public static void main(String[] args) {
    		new InventoryPart6();
    	}
    
    	public InventoryPart6() {
    		products = new ArrayList<Supplier>();
    
    		
    		products.add(new Supplier(500, "STYLUS", 10, 800, "Olympus"));
    		products.add(new Supplier(200, "COOLPIX", 20, 650, "Nikon"));
    		products.add(new Supplier(300, "Powershot", 15, 890, "Canon"));
    		products.add(new Supplier(350, "Cyber-shot", 10, 1200, "Sony"));
    		products.add(new Supplier(400, "Easyshare", 80, 1500, "Kodak"));
    
    		
    		sortArray();
    
    		configureGUI();
    	}
    
    	private void configureGUI() {
    		setTitle("InventoryPart 6");
    		setDefaultCloseOperation(EXIT_ON_CLOSE);
    		setSize(700, 360);
    		setLocationRelativeTo(null);
    
    		logo = new Logo();
    		logo.setPreferredSize(new Dimension(getWidth(), 60));
    		logo.setFont(new Font("Courier New", Font.BOLD, 28));
    		itemData = new JTextArea(12, 40);
    		firstItem = new JButton("First");
    		firstItem.addActionListener(this);
    		previousItem = new JButton("Previous");
    		previousItem.addActionListener(this);
    		nextItem = new JButton("Next");
    		nextItem.addActionListener(this);
    		lastItem = new JButton("Last");
    		lastItem.addActionListener(this);
    		addItem = new JButton("Add");
    		addItem.addActionListener(this);
    		removeItem = new JButton("Remove");
    		removeItem.addActionListener(this);
    		modifyItem = new JButton("Modify");
    		modifyItem.addActionListener(this);
    		saveItems = new JButton("Save");
    		saveItems.addActionListener(this);
    		searchItem = new JButton("Search");
    		searchItem.addActionListener(this);
    
    		setLayout(new BorderLayout());
    
    		JPanel south = new JPanel(new FlowLayout());
    		south.add(firstItem);
    		south.add(previousItem);
    		south.add(nextItem);
    		south.add(lastItem);
    		south.add(addItem);
    		south.add(modifyItem);
    		south.add(removeItem);
    		south.add(searchItem);
    		south.add(saveItems);
    
    		add(logo, BorderLayout.NORTH);
    		add(new JScrollPane(itemData), BorderLayout.CENTER);
    		add(south, BorderLayout.SOUTH);
    
    		setVisible(true);
    		displayItem();
    	}
    
    	
    	
    	public double calculateInventory() {
    		double value = 0;
    		for (int i = 0; i < products.size(); i++) {
    			value += products.get(i).calculateInventory();
    		}
    		return value;
    	}
    
    	
    	public void sortArray() {
    		int n = products.size(); 
    		boolean swapped;
    		do {
    			swapped = false;
    			for (int i = 0; i < n - 1; i++) {
    				Supplier p1 = products.get(i);
    				String name1 = p1.getProductName();
    				Supplier p2 = products.get(i + 1);
    				String name2 = p2.getProductName();
    				if (name1.compareToIgnoreCase(name2) > 0) {
    				
    					Supplier temp = p1;
    					products.set(i, p2);
    					products.set(i + 1, temp);
    					swapped = true;
    				}
    			}
    			n = n - 1;
    		} while (swapped);
    	}
    
    	@Override
    	public void actionPerformed(ActionEvent e) {
    
    		if (firstItem.equals(e.getSource())) {
    			displayFirstItem();
    
    		} else if (previousItem.equals(e.getSource())) {
    			displayPreviousItem();
    
    		} else if (nextItem.equals(e.getSource())) {
    			displayNextItem();
    
    		} else if (lastItem.equals(e.getSource())) {
    			displayLastItem();
    
    		} else if (addItem.equals(e.getSource())) {
    			addItem();
    
    		} else if (removeItem.equals(e.getSource())) {
    			removeItem();
    
    		} else if (modifyItem.equals(e.getSource())) {
    			modifyItem();
    
    		} else if (searchItem.equals(e.getSource())) {
    			seachItem();
    
    		} else if (saveItems.equals(e.getSource())) {
    			saveItems();
    
    		}
    	}
    
    	private void saveItems() {
    		File file;
    
    		file = new File("c:\\data");
    		if (!file.exists()) {
    			file.mkdir();
    		}
    
    		file = new File("c:\\data\\inventory.dat");
    		if (file.exists()) {
    			file.delete();
    		}
    
    		try {
    			file.createNewFile();
    		} catch (IOException ioe) {
    			JOptionPane.showMessageDialog(null,
    					"Failed to create the Inventory file.");
    			return;
    		}
    
    		BufferedWriter writer;
    		try {
    			writer = new BufferedWriter(new FileWriter(file));
    		} catch (IOException e) {
    			JOptionPane.showMessageDialog(null,
    					"Could not create the inventory file.");
    			return;
    		}
    
    		String line;
    		for (int i = 0; i < products.size(); i++) {
    			Supplier product = products.get(i);
    
    			line = product.getProductName() + "\t";
    			line += product.getItemNumber() + "\t";
    			line += product.getPrice() + "\t";
    			line += product.getUnitsInStock() + "\t";
    			line += product.getSupplierName() + "\n";
    
    			try {
    				writer.write(line);
    			} catch (IOException e) {
    				JOptionPane.showMessageDialog(null,
    						"Could not write in the inventory file.");
    			}
    		}
    
    		try {
    			writer.close();
    		} catch (IOException e) {
    			JOptionPane.showMessageDialog(null,
    					"Could not close the inventory file.");
    		}
    
    		JOptionPane.showMessageDialog(null, "File Saved.");
    	}
    
    	private int findByProductName(String name) {
    		int index = -1;
    		for (int i = 0; i < products.size(); i++) {
    			Supplier product = products.get(i);
    			if (product.getProductName().equalsIgnoreCase(name)) {
    				index = i;
    				break;
    			}
    		}
    		return index;
    	}
    
    	private void seachItem() {
    		String productName = JOptionPane
    				.showInputDialog("Enter the product name");
    
    		if (productName != null) {
    			
    			int index = findByProductName(productName);
    
    			if (index != -1) {
    				current = index;
    				displayItem();
    			} else {
    				JOptionPane.showMessageDialog(null, "Product: " + productName
    						+ " does not exist.");
    			}
    		}
    
    	}
    
    	private void modifyItem() {
    		if (current != -1) {
    			
    			String name = promptString("Enter the product name");
    			int units = promptInteger("Enter the number of units");
    			double price = promptDouble("Enter product price");
    			String supplierName = promptString("Enter the supplier name");
    
    			
    			Supplier supplier = products.get(current);
    			supplier.setName(name);
    			supplier.setUnitsInStock(units);
    			supplier.setPrice(price);
    			supplier.setSupplierName(supplierName);
    
    			
    			displayItem();
    		}
    	}
    
    	private void displayLastItem() {
    		
    		current = products.size() - 1;
    		displayItem();
    	}
    
    	private void displayNextItem() {
    		
    		current++;
    		if (current > products.size() - 1) {
    			
    			current = 0;
    		}
    		displayItem();
    	}
    
    	private void displayPreviousItem() {
    		
    		current--;
    		if (current < 0) {
    		
    			current = products.size() - 1;
    		}
    		displayItem();
    	}
    
    	private void displayFirstItem() {
    		
    		current = 0;
    		displayItem();
    	}
    
    	private String prompt(String message) {
    		return JOptionPane.showInputDialog(this, message);
    	}
    
    	private String promptString(String message) {
    		String data = null;
    		do {
    			data = prompt(message);
    		} while (data == null);
    		return data;
    	}
    
    	private int promptInteger(String message) {
    		int data = 0;
    		boolean isValid = false;
    		do {
    			String dataString = prompt(message);
    			if (dataString != null) {
    				try {
    					data = Integer.parseInt(dataString);
    					isValid = true;
    				} catch (Exception e) {
    					isValid = false;
    				}
    			}
    		} while (!isValid);
    		return data;
    	}
    
    	private double promptDouble(String message) {
    		double data = 0;
    		boolean isValid = false;
    		do {
    			String dataString = prompt(message);
    			if (dataString != null) {
    				try {
    					data = Double.parseDouble(dataString);
    					isValid = true;
    				} catch (Exception e) {
    					isValid = false;
    				}
    			}
    		} while (!isValid);
    		return data;
    	}
    
    	private void addItem() {
    		
    		String name = promptString("Enter the product name");
    		int unitsInstock = promptInteger("Enter the number of unitsInstock");
    		double price = promptDouble("Enter product price");
    		String supplierName = promptString("Enter the product supplier");
    
    		
    		Supplier addSupplier = new Supplier();
    		addSupplier.setName(name);
    		if (products.size() > 0) {
    			Supplier lastProduct = products.get(products.size() - 1);
    			addSupplier.setItemNumber(lastProduct.getItemNumber() + 1);
    		} else {
    			addSupplier.setItemNumber(1);
    		}
    		addSupplier.setPrice(price);
    		addSupplier.setUnitsInStock(unitsInstock);
    		addSupplier.setSupplierName(supplierName);
    		products.add(addSupplier);
    
    		
    		displayLastItem();
    	}
    
    	private void removeItem() {
    		if (products.size() > 0) {
    			products.remove(current);
    			displayLastItem();
    		}
    	}
    
    	private void displayItem() {
    		if (current >= 0) {
    			Supplier supplier = products.get(current);
    			StringBuilder sb = new StringBuilder();
    
    			sb.append("Item Number: " + supplier.getItemNumber() + "\n");
    			sb.append("Product Name: " + supplier.getProductName() + "\n");
    			sb.append("Units In Stock: " + supplier.getUnitsInStock() + "\n");
    			sb.append("Unit Price: " + currency.format(supplier.getPrice())
    					+ "\n");
    			sb.append("Supplier Name: " + supplier.getSupplierName() + "\n");
    			sb.append("Inventory  Value: "
    					+ currency.format(supplier.calculateInventory()) + "\n");
    			sb.append("Restock Fee: "
    					+ currency.format(supplier.calculateRestockFee()) + "\n");
    
    			sb.append("\n\nValue of the entire inventory: "
    					+ currency.format(calculateInventory()));
    
    			itemData.setText(sb.toString());
    		} else {
    			itemData.setText(null);
    		}
    	}
    }

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: InventoryPart6 Error

    You haven't made any changes to the line that caused the error.

    You need to use a valid Supplier constructor. You have the Supplier code -- check the constructors and see what form they take. You need to pass the necessary information into constructor. You're already getting this information prior to calling the constructor, so use it.
    Last edited by Fubarable; 10-28-2011 at 02:22 AM.

  6. #6
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: InventoryPart6 Error

    well i just dont understand it i try and i cant drop it now because its my last week so could you just tell me or help me fix it because i am just dumb.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: InventoryPart6 Error

    Quote Originally Posted by MikeJ39 View Post
    well i just dont understand it i try and i cant drop it now because its my last week so could you just tell me or help me fix it because i am just dumb.
    My feeling on grades is that a student should get the grade they deserve, no more, no less. So if you want to get a good grade then study the subject and understand it well. Don't beg for code. Otherwise you are cheapening the grade and in fact stealing from the students who actually do understand the subject.

  8. #8
    Junky's Avatar
    Junky is online now Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: InventoryPart6 Error

    Java Code:
    products.add(new Supplier(500, "STYLUS", 10, 800, "Olympus"));
    Supplier addSupplier = new Supplier();
    Compare those two lines as to how you construct a Supplier object. Since you posted a gazillion lines of code TWICE without including the Supplier class we can only assume that the Supplier class has one constructor that takes int, String, int, int, String as parameters. You are trying to call the default no args constructor which does not exist. You have 2 options. On the line with the error include the necessary parameters or add the default no args constructor to the Supplier class.

  9. #9
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: InventoryPart6 Error

    so you are saying to take off the add?
    off of line 1?

  10. #10
    MikeJ39 is offline Member
    Join Date
    Oct 2011
    Posts
    38
    Rep Power
    0

    Default Re: InventoryPart6 Error

    ok here is my Supplier class
    Java Code:
    class Supplier extends camera {
    
    
    private String supplierName;
    
     
    
    
    
    public Supplier(int itemNumber, String productName, int unitsInStock,
    
    double price, String supplierName) {
    
    
    
    super(itemNumber, productName, unitsInStock, price);
    
    this.supplierName = supplierName;
    
    }
    
    public double calculateRestockFee() {
    
    return super.calculateInventory() * .05;
    
    }
    
    
    public double calculateInventory() {
    
    return super.calculateInventory() + calculateRestockFee();
    
    }
    
    public String getSupplierName() {
    
    return supplierName;
    
    }
    
    public void setSupplierName(String supplierName) {
    
    this.supplierName = supplierName;
    
    }
    
     
    
    }

  11. #11
    Junky's Avatar
    Junky is online now Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: InventoryPart6 Error

    NOOOOOOOOOOOOOOOOOOOO!

    Go back and read about constructors and stop guessing.

  12. #12
    Junky's Avatar
    Junky is online now Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

    Default Re: InventoryPart6 Error

    WTF?

    Why does Supplier extend Camera? I can be a supplier but I am certainly not a Camera.

  13. #13
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. java out of memory error-heap space error
    By elsanthosh in forum NetBeans
    Replies: 4
    Last Post: 06-15-2010, 09:31 AM
  2. Replies: 1
    Last Post: 03-10-2010, 01:53 PM
  3. Replies: 1
    Last Post: 12-05-2009, 07:28 AM
  4. Replies: 1
    Last Post: 10-26-2009, 04:38 PM
  5. Replies: 3
    Last Post: 01-23-2009, 08:53 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •