Question

Use Java please...

Activity 1. Suppose we want to have an object-oriented design for an invoicing system, that includes invoices, one or more li

1 0
Add a comment Improve this question Transcribed image text
Answer #1

1. Finding Classes • Keep the following points in mind: • Class represents set of objects with the same behavior • Entities with

2. Case Study: Printing an Invoice – CRC Cards • Discover classes • Nouns are possible classes: Invoice Address LineItem Product

3. Case Study: Printing an Invoice — CRC Cards • Analyze classes: // Records the product and the quantity Invoice Address LineIt

4. CRC Card • Indicate what other classes are needed to fulfill responsibility (collaborators) Class Responsibilities Invoice Co

5. CRC Cards for Printing Invoice Invoice and Address must be able to format themselves: Invoice format the invoice Address form

6. CRC Cards for Printing Invoice Product and LineItem CRC cards: Product get description get unit price LineItem Product format

7.

CRC Cards for Printing Invoice Invoice must be populated with products and quantities: Invoice format the invoice Address add8.

Printing an Invoice — UML Diagrams Invoice Address Product LineItem Figure 7 The Relationships Between the Invoice Classes9.

Method Documentation - Invoice Class /** Describes an invoice for a set of purchased products. * public class Invoice /** Add10.

Method Documentation — Invoice Class (cont.) /** Formats the invoice. @return the formatted invoice */ public String format (11.

Method Documentation – LineItem Class Describes a quantity of an article to purchase and its price. public class LineItem /**12.

Method Documentation – LineItem Class (cont.) /** Formats this item. @return a formatted string of this line item */ public S13.

Method Documentation - Product Class (cont.) Gets the product price. @return the unit price public double get Price ()14.

Method Documentation - Address Class /** Describes a mailing address. public class Address /** Formats the address. @return t15.

Implementation • Invoice aggregates Address and LineItem • Every invoice has one billing address • An invoice can have many l16.

Implementation A line item needs to store a Product object and quantity: public class Line Item private int quantity; private17.

Implementation • The methods themselves are now very easy • Example: • getTotal Price of LineItem gets the unit price of the18.

2 3 This program demonstrates the invoice classes by printing a sample invoice. public class InvoicePrinter public static voi19.

1 import java.util.ArrayList; 5 Describes an invoice for a set of purchased products. */ public class Invoice private Address20.

Adds a charge for a product to this invoice. @param aProduct the product that the customer ordered @param quantity the quanti21.

Formats the invoice. @return the formatted invoice public String format) String r = INVOICE\n\n + billingAddress. format (22.

Computes the total amount due. @return the amount due public double getAmount Due() double amount Due = 0; for (LineItem item23.

1 ** 2 Describes a quantity of an article to purchase. 3 */ 4 public class Line Item 5 private int quantity; private Product

24.

Computes the total cost of this line item. @return the total price public double getTotalPrice () return the product.getPrice25.

2 3 Describes a product with a description and a price. */ public class Product private String description; private double pr

26.

Gets the product description. @return the description public String getDescription() return description; Gets the product pri27.

1 ** 2 3 Describes a mailing address. */ public class Address 4 private String name; private String street; private String ci28.

public Address (String aName, String aStreet, String a City, String aState, String a Zip) name = aName; street = aStreet; cit

Add a comment
Know the answer?
Add Answer to:
Use Java please... Activity 1. Suppose we want to have an object-oriented design for an invoicing...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java is an object-oriented programming language that enables us to define classes and to instantiate them...

    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...

  • Java 1. Develop a program to emulate a purchase transaction at a retail store. This program...

    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...

  • Concepts Tested in this Program: Class Design Constructors Objects Inheritance Program:   Design a class named Person...

    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...

  • In c# So far, you have created object-oriented code for individual classes. You have built objects...

    In c# So far, you have created object-oriented code for individual classes. You have built objects from these classes. Last week, you created a UML for new inherited classes and objects. Finally, you have used polymorphism. When you add abstraction to this mix, you have the “4 Pillars of OOP.” Now, you begin putting the pieces together to create larger object-oriented programs. Objectives for the project are: Create OO classes that contain inherited and polymorphic members Create abstracted classes and...

  • can you solve it in java please Create the following: 1. Class Invoice ( the node...

    can you solve it in java please Create the following: 1. Class Invoice ( the node ) that includes three instance variables:     int No; // the Invoice No             String CustName; // the Customer name             int Amount; // the Invoice Amount Invoice next; // points to the next Invoice Default and overloaded constructors 2. Class Shop that includes three instance variables: Invoice head; Invoice Tail; Your class should have the following: • A method that initializes the instance variables....

  • JAVA INTERFACE 1.Suppose you want to design a class that is given numbers one at a...

    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...

  • This is a java program that runs on the Eclipse. Java Programming 2-1: Java Class Design...

    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,...

  • in BASIC/BEGINNER OBJECT ORIENTATED JAVA Please write code for the following program using comments explaining the...

    in BASIC/BEGINNER OBJECT ORIENTATED JAVA Please write code for the following program using comments explaining the code. (You can hand write this). Give a UML example illustrating AGGREGATION. Include classes, fields, methods, instance fields. USE ONE SUPER CLASS AND TWO SUB CLASSES. Include pcode for at least one method of each class. Explain the whole part relationship and if this a deep or shallow copy.

  • The purpose of this homework is to practice OOP programming covering Inheritance in java. The scenario...

    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...

  • ********************Java Assigment******************************* 1. The following interface and classes have to do with the storage of information...

    ********************Java Assigment******************************* 1. The following interface and classes have to do with the storage of information that may appear on a mailing label. Design and implement each of the described classes below. public interface AddrLabelInterface { String getAttnName(); String getTitle(); // Mr., Mrs., etc. String getName(); String getNameSuffix(); // e.g., Jr., III String getProfessionalSuffix(); // O.D. (doctor of optometry) String getStreet(); String getSuiteNum(); String getCity(); String getState(); String getZipCode(); } Step 1 Create an abstract AddrLabel class that implements the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT