Java
Activity 1.
Suppose we want to have an object-oriented design for an invoicing system, that includes invoices, one or more line items in each invoice, address of the invoice, list of products, etc. Try to design this system by indicating the required classes, responsibilities of each class, and the collaborating classes to fulfill each responsibility, and draw the CRC cards as well as UML diagram of the classes and their relationships. Then, indicate the methods of each class, provide Java documentation for each method, and then implement the classes. Beside any methods you realize, make sure you have the following functionalities for this system: • A method to format the invoice and return it as a String. • A method to compute and return the amount due of an invoice. • A method to add one LineItem object to the invoice. • A method to format a given LineItem object and return it as a String. • A method to format the Address object and return it as a String. • Two methods to change/set the values of description and unit price of the Product object.
Activity 2.
In the previous activity, you completed the invoice creation and print tasks. Now, suppose that you want an extra functionality into the requirements as follows: You are asked to keep the available quantity of every product, and at the time of creating a new line item, you should check if enough number of quantity of the given product is available. Otherwise, you should change a flag for that product that indicates “OutOfStock” and ignore adding the new line item into the invoice. Try to modify the corresponding classes to fulfill this new requirement.
Below is my Java code. The out of stock feature asked in Activity 2 is implemented in the "addLineItem" function of the "Invoice" class.
import java.io.*;
import java.util.*;
class Product {
int id, quantitiy_in_stock, price;
boolean out_of_stock;
Product(int i, int q, int p) {
this.id = i;
this.quantitiy_in_stock = q;
this.price = p;
if (q > 0) {
this.out_of_stock = false;
}
else {
this.out_of_stock = true;
}
}
}
class LineItem {
Product product;
int quantity, amount;
LineItem(Product p, int q) {
this.product = p;
this.quantity = q;
this.amount = p.price * q;
}
}
class Invoice {
List<LineItem> lineItemList;
Invoice() {
this.lineItemList = new ArrayList<>();
}
void addLineItem(Product product, int quantity) {
if ((product.out_of_stock) || (product.quantitiy_in_stock <
quantity)) {
product.out_of_stock = true;
}
else {
this.lineItemList.add(new LineItem(product, quantity));
}
}
}
Java Activity 1. Suppose we want to have an object-oriented design for an invoicing system, that...
Use Java please...
Activity 1. Suppose we want to have an object-oriented design for an invoicing system, that includes invoices, one or more line items in each invoice, address of the invoice, list of products, etc. Try to design this system by indicating the required classes, responsibilities of each class, and the collaborating classes to fulfill each responsibility, and draw the CRC cards as well as UML diagram of the classes and their relationships. Then, indicate the methods of each...
Java 1. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual line item of merchandise that a customer is purchasing. The Transaction class will combine several LineItem objects and calculate an overall total price for the line item within the transaction. There will also be two test classes, one for the LineItem class and one for the...
The purpose of this project is to give students more exposure to object oriented design and programming using classes and polymorphism in a realistic application that involves arrays of objects and sorting arrays containing objects A large veterinarian services many pets and their owners. As new pets are added to the population of pets being serviced, their information is entered into a flat text file. Each month the vet requests and updates listing of all pets sorted by their "outstanding...
This is a java program that runs on the Eclipse.
Java Programming 2-1: Java Class Design Interfaces Practice Activities Lesson objectives: Model business problems using Java classes Make classes immutable User Interfaces Vocabulary: Identify the vocabulary word for each definition below. A specialized method that creates an instance of a class. A keyword that qualifies a variable as a constant and prevents a method from being overridden in a subclass. A class that it can't be overridden by a subclass,...
Java is an object-oriented programming language that enables us to define classes and to instantiate them into objects. These objects then call each other’s methods to implement the behavior of the application. The Unified Modeling Language (UML) is an object-oriented visual notation to document the design of object-oriented classes. For this discussion, you will practice designing a Java class called Course, drawing a UML class diagram for the Course class, and then implementing the Course class in Java code. Review...
This Java program must use classes and object-oriented design (OOD) as I'm in a more advanced Java class. (Sales Commission Calculator) A large company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of merchandise in a week receives $200 plus 9% of $5000, or a total of $650. You’ve been supplied with a list of the items sold...
Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program: Design a class named Person and its two subclasses, Student and Employee. Make Faculty and Staff subclasses of Employee. A Person object has a name, address, phone number, and email address (all Strings). A Student Object has a class status (freshman, sophomore, junior, or senior). Define the status as a final String variable. An Employee Object has an office number, salary (both ints ), and a date hired. Use...
JAVA INTERFACE 1.Suppose you want to design a class that is given numbers one at a time. The class computes the smallest, second smallest, and average of the numbers that have been seen so far. Create an interface for the class. Create a class that implements the interface. 2. Create an interface Measurable with methods getarea( )and getperimeter(). Implement it in two classes Circle, and Square . Both the classes should have Constructor for initializing the dimensions, and define the...
For this question, we want to implement the basic java classes to support the concept of an Online Store and a shopping cart. Consider an e-store with various types of items: books, flowers, gift cards, etc... and we like to be able to support the ability to handle a shopping cart that can contain various types of items. For this question you are asked to create the following classes: abstract class: “Item” every item has a unique item_id (a positive integer,...
The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario is to design an online shopping system for a local supermarket (e.g., Europa Foods Supermarket or Wang Long Oriental Supermarket) and is mostly concentrated on the product registration system. Design and draw a UML diagram, and write the code for the following classes: ID: The identification number must start with 1 and follows with 6 numbers, e.g., “1123456”. Description, e.g. “Banana” Recommended Price per...