{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Intro to Java Web-Notes_Part78

Intro to Java Web-Notes_Part78 - The code for the five...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: The code for the five classes is shown below. First is all ofthe code for the classes in the sales class, kept in three separate files: // // File: Order.java // package com.kiowok.sales; public class Order { private int orderNum; public Order(int orderNum) l if (orderNum > O) this.orderNum = orderNum; l public String toString() i return "Order: " + this.orderNum; l } // // File SpecialOrder.java // package com.kiowok.sales; public class SpecialOrder extends Order { private int priority; // l to 10 range public static final int MIN_PRIO = 1; public static final int MAX_PRIO = 10; public SpecialOrder<int orderNum, int priority) l super(orderNum); if (priority >= MINiPRIO && priority <= MAXiPRIO) this.priority = priority; else this.priority = MINiPRIO; } public String toString() { return "Special Order —— priority " + priority + ", " + super.toString(); } } // // File: CreateOrder.java // package com.kiowok.sales; public class CreateOrder { public static void main(String args) { Order ol = new Order(l); System.out.println(ol); SpecialOrder rush = new SpecialOrder(2, SpecialOrder.MAXiPRIO); System.out.println(rush); Here is the code for the classes in the clients package (kept in two different Java files): // // File: Customer.java // package com.kiowok.clients; import com.kiowok.sales.Order; public class Customer { public static void main(String args) { Ord r 0rd rSho s t n w Ord r(3); System.out.println(orderShoes); Complaint pants = new Complaint(4, "Too short"); System.out.println(pants); // // File: Complaint.java // package com.kiowok.clients; import com.kiowok.sales.Order; public class Complaint extends Order { private String description; public Complaint(int order, String description) { super(order); this.description = description; } public String tostring() { return "Complaint about " + super.toString() + " —— " + this.description; } ...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern