Java Assignment

   Exercise 1 [5 points]:  Create the forthcoming rankes shown in the UML diagram. Then, form PointTest.java rank following a while main process to standard all functionality of these rankes.    Exercise 2 [10 points]:  The forthcoming shape shows a UML diagram in which the rank Novice is lineal from the rank  Person  a. Instrument a Idiosyncratic rank. The idiosyncratic originator takes two strings: a primeval spectry and a conclusive spectry. The originator primalizes the email address to the primeval missive of the primeval spectry followed by primeval five missives of the conclusive spectry followed by @tru.ca. If the conclusive spectry has fewer than five missives, the e-mail address conciliate be the primeval missive of the primeval spectry followed by the total conclusive spectry followed by a @tru.ca. Examples:     Name  Email Address    Jane Smith  [email protected]    Musfiq Rahman  [email protected]    John Morris  [email protected]    Mary Key  [email protected]    b. Override Object’s toString process for the Idiosyncratic rank. The toString process should repay the offer narrate of the appearance.  c. Now, form a Novice rank that is a subrank of Idiosyncratic and instruments Comparoperative interface.  d. The Novice originator conciliate be determined following a while two String parameters, the primeval spectry and conclusive spectry of the novice. When the novice is fictitious, the lineal fields conclusiveName, primevalName, and email conciliate be truly primalized, the novice’s gpa and compute of reputation conciliate be set to 0. The capricious conclusiveIdAssigend conciliate be truly incremented each span a Novice appearance is fictitious and the noviceId conciliate be set to the proximate profitoperative ID compute as tracked by the rank capricious conclusiveIdAssigend.  e. Override the appearance’s toString process for the Novice rank. The toString process should repay the offer narrate of the appearance. Note that it should use the toString() process from its superclass.   f. The addCourse() process should update the reputations completed, compute, and update the gpa treasure.  Use the forthcoming treasures for grade:    Example GPA calculation:  GRADE    CREDIT    CALCULATION  (A) 4.0  x  4    =  16.00  (B) 3.0  x  4    =  12.00  (B) 3.0  x  4    =  12.00  (A) 4.0  x  1    =  4.00  (C) 2.0  x  3    =  6.00  GPA = 50.00 / 16 = 3.125; the getGPA() process should repay this treasure.  g. Students are compared to each other by comparing GPAs. Override the compareTo() process for the novice rank. Note that to override the compareTo() process, the Novice rank must instrument Comparoperative interface.  Now, standard your enactment following a while the affordd client enactment (StudentClient.java). Note: You should not modify this client enactment. We conciliate use the selfselfselfselfsimilar client enactment to standard your rankes.   Exercise 3 [10 points]:  In this application, you demand to instrument a rank that encapsulate a Grid. A grid is a profitoperative concept in creating board-recreation applications. Following we conciliate use this rank to form a board recreation. A grid is a two-dimensional matrix (see copy beneath) following a while the selfselfselfselfsimilar compute of rows and posts. You can form a grid of bulk 8, for copy, it’s an 8x8 grid. There are 64 cells in this grid. A cell in the grid can possess any harsh treasure. Following in this career, we conciliate imbibe how to form a cell that can stop any harsh treasures. However, for the span nature, we conciliate exhibit that the cell-values are non-negative integers. If a cell contains a treapermanent ‘0’ that media, the cell is space. To fulfill a cell, you demand row compute and post compute, for copy, cell (1, 3) media 3rd cell of the  1st row. You demand to form a rank that satisfies the forthcoming conditions.  Tasks  Write standards and enactment for each of the forthcoming conditions, in prescribe. The opinion in adventurous evidence intimation spectrys. Whenever a condition says the user can "ask whether...", the expected response is boolean. Whenever a condition speaks of a "particular" individual, then that individual conciliate be an controversy to the process.  1. The user can form a Grid stateing the compute of row and post. Also the user can form a Grid stateing the bulk simply.  2. The user can ask a Grid whether its isEmpty. A grid is space when all the cells of the grid is space.  3. The user can plain all the cells of the grid. It’s a unfilled process.  4. The user can ask a Grid whether a detail cell isValid.  5. The user can ask a Grid to set a detail treapermanent by setValue to a detail row and col. The grid sets the treapermanent simply if that cell is sufficient.  6. The user can ask a Grid to getValue (in this condition integer) from a detail row and col. The grid repays the treapermanent simply if the locations are sufficient.  7. The user can ask a Grid to set tend-apart-among-floating of its row and post following a while detail treasures. Example, setCells(int rows[], int cols[], int vals[]), in this process user can state the indexes of rows and posts that the user lacks to set following a while some detail treasures (provided in vals set-in-order). Note that, rows, cols, and vals set-in-orders should be of selfselfselfselfsimilar bulk.  8. Fashion another overridden process for setCells(int rows[], int cols[], int v), that conciliate set detail rows and cols of a grid following a while a detail treasure.  Apart-floating from these basic conditions, reach unconditional to add further bearings to the Grid rank that you judge following a whilehold. Please afford sense for those bearings as a illustrate in the fount improve.  Write a standard rank to standard the behaviours of the Grid rank and suggest the standard rank as courteous-behaved.  Note: A grid is tight of numerous cells. So, you may lack to rework-out the grid into a Cell rank that encapsulates all the requisite bearing of a cell in the grid  Exercise 4 [10 points]:  Introduction  This application asks you to instrument a narrow rank that conciliate following subsubserve as tend-apart-among-floating of larger programs. You conciliate instrument a new husk of compute, a BoundedInteger.  When we transcribe programs to is-sue-out problems in the globe, we repeatedly demand to copy detail husks of treasures, and those treasures don't resemblingity up following a while the quaint types in our program talk. For copy, if we were communication a program to instrument a clock or a enlist, then we would demand computes to reoffer microscopics or days. But these computes aren't Java integers, which rank from -231to 231-1; they rank from 0 to 59 and 1 to 31 (or close!), respectively. Java's worthiest types are profitoperative architecture blocks, but at the plane of atoms, not molecules.  Tasks  Write a rank for dramatizeing restricted integers.  A restricted integer takes integer treasures following a whilein a fond rank. For copy, the microscopics tend-apart-among-floating of a span takes treasures in the rank [0..59]. The proximate microscopic following 59 is 0. The microscopic precedently 0 is 59.  Object creation  We lack to be operative to form restricted integers in two ways.  1. We state the appearance's inferior jump, its better jump, and its primal treasure.  2. We state simply the appearance's inferior jump and its better jump. The appearance's primal treapermanent is the selfselfselfselfsimilar as its inferior jump.  Of career, this media that you demand to transcribe two originators.  We would enjoy to be operative to use restricted integers in considerefficient the selfselfselfselfsimilar way we use systematic ints.  Arithmetic operations  We would enjoy to be operative to:  • add an int to a restricted integer.  • deduct an int from it.  • increment and debasement it.  A restricted integer "wraps around" when it does such arithmetic. For copy, assume that we possess a microscopics restricted integer whose treapermanent is 52. Adding 10 to this appearance affords it a treapermanent of 2.  Value operations  We would enjoy to be operative to:  • ask a restricted integer for its treapermanent as an int.  • substitute its treapermanent to an harsh int.  • imimimprint its treapermanent out. The way to do this in Java is for the appearance to suit to toString() intimation by repaying a String that can be imprinted.  If we try to set a restricted integer to a treapermanent without of its rank, the appearance should tend its vulgar treapermanent and imimimprint an hallucination intimation to System.err. or System.out.  Comparison operations  We would enjoy to be operative to:  • ask one restricted integer if it is resembling to another.  • ask one restricted integer if it is close than another.  • ask a restricted integer if a detail int is a allowable treapermanent for the restricted integer. For copy, 23 is a allowable treapermanent for the microscopics restricted integer, but 67 is not.  The response to each of these questions is gentleman or untrue.  You may instrument these conditions in any prescribe you divert, though you'll demand at insignificanexperiment one originator precedently you can standard any of the others. Transcribe a rank to standard your enactment and suggest that standard rank as courteous-behaved.  Some Suggestions for Coding:  To transcribe your program, primeval transcribe a standard that expresses what you would enjoy your enactment to do, and then transcribe the enactment to do it. Take narrow steps, and your standards conciliate afford you feedback as early as practicable.  Exercise 5 [15 Points]  For this application, you conciliate project a set of rankes that is-sue concurrently to assume a parking administrator checking a parked car issuing a parking ticket if there is a parking violation. Here are the rankes that demand to collaborate:  • The ParkedCar rank: This rank should assume a parked car. The car has a fashion, copy, pretense, indulge compute.  • The ParkingMeter rank: This rank should assume a parking meter. The rank has three parameters:  − A 5-digit ID that identifies the meter.  − A intimation to the car (ParkedCar appearance) that is vulgarly parked at the meter. If no car is parked, this parameter should be set to trifling (in this condition, fashion permanent to repay “Car: none” in your toString process).  − Whether the meter has expired or not.  − The vulgar span (you may assume the vulgar span).  • The ParkingTicket rank: This rank should assume a parking ticket. The rank should report:  − The fashion, copy, pretense and indulge compute of the illegally parked car.  − Meter ID  − The vulgar span.  − The aggregate of choice, which is $25 if the meter has expired and the vulgar span is betwixt 9 a.m. and 5 p.m. and $10 if the meter has expired and the vulgar span is betwixt 5.01 p.m. and 8.59 a.m.  − The spectry and sign compute of the police administrator issuing the ticket (DO NOT place-of-business ParkingOfficer appearance).  • The ParkingOfficer rank: This rank should assume a parking administrator inspecting parked cars. The rank has  − Officer’s spectry and sign compute  − isExpired process that examines the ParkingMeter appearance and determines whether the meter has expired.  − A process that examines the fond parking meter and repays a parking ticket (generates a ParkingTicket appearance) if the meter has expired. If it is not expired or no car is parked at the meter, repay trifling treasure.  You may conceive request capriciouss and social interfaces in each rank as you may invent following a whilehold. Also add following a whilehold hallucination checks.  Write a client program that demonstrates how these rankes collaborate. In union, you should form a UML diagram for demonstrating relation floating the rankes and suggest that UML as tend-apart-among-floating of your acquiescence.  Here are some copys of your output. They demand not be correspondently as shown. Reach unconditional to be mental, but you should standard your program for all conditions.  Parking Meter: 34521 Time: 8.00 p.m.  No car parked.  Parking Meter: 45673 Time: 4.54 p.m.  Car Parked: Lexus ES350, Black, ABC123  Meter: Not expired  Parking Meter: 98764 Time: 5.01 p.m.  Car Parked: Toyota Camry, Red, EFL786  Meter: Expired  Parking Ticket Issued  Toyota Camry, Red, EFL786  Meter ID: 98764 Time: 5.01 p.m.  Fine Amount: $10  Issuing Officer: G.Bertrand, IO5674