2 題 Java 程式
可以把中間的Code ??出??? 1. Complete the following definition of the static method OrderByCode that inputs an ArrayList items of MenuItems and returns a new ArrayList of MenuItems containing all the menu items (regardless of whether or not they are available) with all the appetizers listed first, all the entrees listed next, and all the desserts listed last. Method: public static ArrayList<MenuItem> OrderByCode( ArrayList<MenuItem> items ) { ...? } ArrayList<MenuItem> items = new ArrayList<MenuItem>(); d( new MenuItem( "Big Bad Burger", 9.95, 2.15, 1, true ) ); d( new MenuItem( "Cheeky Chicken", 5.95, 0.75, 1, true ) ); d( new MenuItem( "Wild Wings", 5.95, 0.50, 0, true ) ); d( new MenuItem( "Flying Fish", 15.95, 7.61, 1, false ) ); d( new MenuItem( "Igloo Icecream", 1.95, 0.28, 2, true ) ); ArrayList<MenuItem> ordered = OrderByCode( items ); for ( MenuItem item : ordered ) intln( nuString() ); Result: Wings, Burger, Chicken, Fish, Icecream .... Hint: create a new ArrayList of MenuItems and add elements of the input to it, those with code 0 first, then those with code 1, and finally those with code 2. Finally, return the new ArrayList. 2. Complete the following definition of the static method AvailableItems that inputs an ArrayList items of MenuItems and returns a new ArrayList of MenuItems containing just those menu items that are currently available. Method: public static ArrayList<MenuItem> AvailableItems( ArrayList<MenuItem> items ) { ....? } ArrayList<MenuItem> items = new ArrayList<MenuItem>(); d( new MenuItem( "Big Bad Burger", 9.95, 2.15, 1, false ) ); d( new MenuItem( "Cheeky Chicken", 5.95, 0.75, 1, true ) ); d( new MenuItem( "Wild Wings", 5.95, 0.50, 0, false ) ); d( new MenuItem( "Flying Fish", 15.95, 7.61, 1, false ) ); d( new MenuItem( "Igloo Icecream", 1.95, 0.28, 2, true ) ); ArrayList<MenuItem> available = AvailableItems( items ); for ( MenuItem item : available ) intln( nuString() ); Result: Cheeky Chicken ($5.95) and Igloo Icecream ($1.95)...... Hint: Just create a new ArrayList of MenuItems and add elements of the input to it according as they're available or not. Then return the new ArrayList. Five lines of code max in the body of the method.
1。 public static ArrayList AvailableItems( ArrayList items ) { ArrayList temp = new ArrayList(); for ( MenuItem item :items ) if (item。
Available()) d(new MenuItem(item。GetName(), item。GetPrice(), item。GetCost(), item。GetCode(), item。
Available())); return temp; } public static void main(String[] args) { ArrayList items = new ArrayList(); d( new MenuItem( "Big Bad Burger", 9。
95, 2。15, 1, false ) ); d( new MenuItem( "Cheeky Chicken", 5。95, 0。75, 1, true ) ); d( new MenuItem( "Wild Wings", 5。
95, 0。50, 0, false ) ); d( new MenuItem( "Flying Fish", 15。95, 7。61, 1, false ) ); d( new MenuItem( "Igloo Icecream", 1。
95, 0。28, 2, true ) ); ArrayList available = AvailableItems( items ); for ( MenuItem item : available ) intln( nuString() ); } } 2。
public static ArrayList OrderByCode( ArrayList items ) { ArrayList temp = new ArrayList(); if ( Empty()) return temp; //?]有說code的範??要找出minimum, maximum int max= t(0)。
GetCode(); int min=max; for ( MenuItem item : items ) { int code =item。GetCode(); if (code > max) max=code; if (code items = new ArrayList(); d( new MenuItem( "Big Bad Burger", 9。
95, 2。15, 1, true ) ); d( new MenuItem( "Cheeky Chicken", 5。95, 0。75, 1, true ) ); d( new MenuItem( "Wild Wings", 5。95, 0。
50, 0, true ) ); d( new MenuItem( "Flying Fish", 15。95, 7。61, 1, false ) ); d( new MenuItem( "Igloo Icecream", 1。95, 0。
28, 2, true ) ); ArrayList ordered = OrderByCode( items ); for ( MenuItem item : ordered ) intln( nuString() ); } } 。
兄弟:你这题目我看了好几次 第一个看出个所以然来了,可MenuItem类的定义不知道,所以也不知道怎么去写,第二个题硬是连题目的意思都没搞懂,我很遗憾
答:cooledit2.1是录音软件。 推荐使用:Adobe Audition 2.0┊专业级音频编辑┊汉化免安装增强版 整合的音讯录制、混音、编辑和掌握!以强大的...详情>>
答:google "java 缓冲池"详情>>
答:百度里搜张孝祥 非常好的视频教程详情>>