Intro to Java Web-Notes_Part78

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

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

View Full Document Right Arrow Icon
Background image of page 1

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

View Full DocumentRight Arrow Icon
Background 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

This note was uploaded on 11/17/2010 for the course CIS 1500 taught by Professor Staff during the Summer '08 term at Oakland CC.

Page1 / 2

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

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online