第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

JAVA Linked Lists問題

JAVA Linked Lists問題

0C13602793 2016-07-05 07:30:58
題目和要求: In?this?question,?you?will?write?a?linked?list?class,?and?use?it?to?store?all?of?the?words?contained?in?a?text?file. You?will?write?your?linked?list?class?in?a?file?called?LinkedList.java,?which?will?contain?BOTH?the LinkedList?class?and?the?Node?class?(only?the?LinkedList?class?is?public). You?have?been?provided?with?a?main?program?file?called?A4Test.java?and?a?text?file?called darwin.txt. First,?create?a?Node?class.?It?should?contain,?as?usual,?a?pointer?to?another?node,?and?a?String?reference. Write?a?constructor?that?sets?the?data?being?stored?in?the?Node,?and?set?its?link?to?the?next?Node?to?null. Write?appropriate?getters?and?setters?as?well. Next,?create?your?LinkedList?class.?As?usual,?it?should?contain?a?first?(top)?pointer?to?the?first?node?in the?list.?Additionally,?create?a?last?pointer?to?the?last?Node?in?the?linked?list?(we’ll?see?why?later).?Add?an integer?instance?variable?to?keep?track?of?the?size?(i.e.?the?number?of?words)?in?the?linked?list. Create?the?following?public?methods: ??A?null?constructor?that?initializes?the?two?Node?pointers?to?null?and?the?size?to?0 ??int?size()?that?returns?the?size?of?the?list. ??void?append(String),?which?takes?the?given?word?and?places?it?at?the?end?of?the?list,?not?at the?beginning.?Instead?of?performing?a?costly?traversal?of?the?linked?list?from?the?beginning until?the?end?is?reached,?use?the?last?pointer?instead,?when?appending?a?new?item.?Be?mindful of?the?case?when?the?list?is?empty. ??A?second?constructor?that?takes?a?String?parameter,?which?is?the?name?of?a?file.?The constructor?will?attempt?to?read?the?file?and?add?all?the?words?in?the?file?to?the?linked?list?(using append).?Use?whitespace?to?separate?the?lines?into?words.?In?Java,?the?String?literal "\\p{Space}+"?specifies?one?or?more?whitespace?characters. ??String?format(int?width)?that?returns?a?String?containing?all?the?words?in?their?original order,?formatted?in?lines?that?are?width?characters?long,?fully?justified?(i.e.?the?lines?are?aligned on?both?the?left?and?right?sides).?This?is?achieved?by?adding?extra?spaces?between?the?words?so that?the?right?side?is?aligned?at?width?characters.?In?order?to?make?the?justification?look balanced,?distribute?the?extra?spaces?throughout?the?line.?Add?the?extra?spaces?left-to-right?on each?second?line,?and?right-to-left?on?the?alternating?lines.?You?may?find?it?helpful?to?use?two private?methods?to?perform?these?justification?steps?(though?you?are?not?required?to?do?so).?The last?line?is?not?justified,?since?it?may?contain?only?a?few?words. A4test?code: public?class?A4Test{ ??public?static?void?main(String?[]?args){ ????String?fileName?=?"darwin.txt"; ????System.out.println("This?is?A4Test.\n"); ????LinkedList?myList?=?new?LinkedList(fileName); ????System.out.println(myList.format(80)); ????System.out.println(fileName?+?"?contains?"?+?myList.size()?+?"?words."); ??}//?main }//?class?A4Test drawin.txt內(nèi)容: qwertyuiopasdfghjklzxcvbnm
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1817 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號