Rebuilding study Note 1

Source: Internet
Author: User

 

Import Java. util. *; <br/> public class movie <br/>{< br/> Public static final int childrens = 2; <br/> Public static final int regular = 0; <br/> Public static final int new_release = 1; <br/> private string _ title; <br/> private int _ pricecode; <br/> Public movie (String title, int pricecode) <br/>{< br/> _ Title = title; <br/> _ pricecode = pricecode; <br/>}< br/> Public int getpricecode () <br/>{< br/> return _ pricecode; <br/>}< br/> Public void setpricecode (INT Arg) <br/>{< br/> _ pricecode = ARG; <br/>}< br/> Public String gettitle () <br/>{< br/> return _ title; <br/>}< br/> class Marshal <br/>{< br/> private movie _ movie; <br/> private int _ daysrented; <br/> Public Marshal (movie, int daysrented) <br/>{< br/> _ movie = movie; <br/> _ daysrented = daysrented; <br/>}< br/> Public int getdaysrented () <br/>{< br/> return _ daysrented; <br/>}< br/> Public movie getmovie () <br/>{< br/> return _ movie; <br/>}< br/> Class Customer <br/>{< br/> private string _ name; <br/> private vector _ uploals = new vector (); <br/> Public customer (string name) <br/>{< br/> _ name = Name; <br/>}< br/> Public void addrental (Marshal Arg) <br/>{< br/> _ marshals. addelement (ARG); <br/>}< br/> Public String getname () <br/>{< br/> return _ name; <br/>}< br/> Public String Statement () <br/>{< br/> double totalamount = 0; <br/> int frequentrenterpoints = 0; <br/> enumeration required als = _ required ALS. elements (); <br/> string result = "Marshal record for" + getname () + "/N"; <br/> while (grouping ALS. hasmoreelements () <br/>{< br/> double thisamount = 0; <br/> Marshal each = (Marshal) Marshals. nextelement (); <br/> switch (each. getmovie (). getpricecode () <br/>{< br/> case movie. regular: <br/> thisamount + = 2; <br/> If (each. getdaysrented ()> 2) <br/> thisamount + = (each. getdaysrented ()-2) * 1.5; <br/> break; <br/> case movie. new_release: <br/> thisamount + = each. getdaysrented () * 3; <br/> break; <br/> case movie. childrens: <br/> thisamount + = 1.5; <br/> If (each. getdaysrented ()> 3) <br/> thisamount + = (each. getdaysrented ()-3) * 1.5; <br/> break; <br/>}< br/> frequentrenterpoints ++; <br/> If (each. getmovie (). getpricecode () = movie. new_release & each. getdaysrented ()> 1) <br/> frequentrenterpoints ++; <br/> result + = "/t" + each. getmovie (). gettitle () + "/t" + <br/> string. valueof (thisamount) + "/N"; <br/> totalamount + = thisamount; <br/>}< br/> result + = "amount owed is" + String. valueof (totalamount) + "/N"; <br/> result + = "you earned" + String. valueof (frequentrenterpoints) + <br/> "Frequent renter points"; <br/> return result; <br/>}< br/>} 

 

Import Java. util. *; <br/> class customer2 <br/> {<br/> private string _ name; <br/> private vector _ als = new vector (); <br/> Public customer2 (string name) <br/>{< br/> _ name = Name; <br/>}< br/> Public void addrental (invalid Al Arg) <br/>{< br/> _ ALS. addelement (ARG); <br/>}< br/> Public String getname () <br/>{< br/> return _ name; <br/>}< br/> Public String Statement () <br/>{< br/> double totalamount = 0; <br/> int frequentrenterpoints = 0; <br/> enumeration required als = _ required ALS. elements (); <br/> string result = "Marshal record for" + getname () + "/N"; <br/> while (grouping ALS. hasmoreelements () <br/>{< br/> double thisamount = 0; <br/> Marshal each = (Marshal) Marshals. nextelement (); <br/> amountfor (each); <br/> frequentrenterpoints ++; <br/> If (each. getmovie (). getpricecode () = movie. new_release & each. getdaysrented ()> 1) <br/> frequentrenterpoints ++; <br/> result + = "/t" + each. getmovie (). gettitle () + "/t" + <br/> string. valueof (thisamount) + "/N"; <br/> totalamount + = thisamount; <br/>}< br/> result + = "amount owed is" + String. valueof (totalamount) + "/N"; <br/> result + = "you earned" + String. valueof (frequentrenterpoints) + <br/> "Frequent renter points"; <br/> return result; <br/>}< br/> private double amountfor (Marshal each) <br/>{< br/> double thisamount = 0; <br/> switch (each. getmovie (). getpricecode () <br/>{< br/> case movie. regular: <br/> thisamount + = 2; <br/> If (each. getdaysrented ()> 2) <br/> thisamount + = (each. getdaysrented ()-2) * 1.5; <br/> break; <br/> case movie. new_release: <br/> thisamount + = each. getdaysrented () * 3; <br/> break; <br/> case movie. childrens: <br/> thisamount + = 1.5; <br/> If (each. getdaysrented ()> 3) <br/> thisamount + = (each. getdaysrented ()-3) * 1.5; <br/> break; <br/>}< br/> return thisamount; <br/>}< br/>} 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.