Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Sell your Land, House on idamata.lk for FREE
sajith.xp.pk
Updated:
Today at 9:03 AM
Handmade Character Soft Toys
anil1961
Updated:
Tuesday at 2:11 PM
Bodim.lk out now !
Manoj Suranga Bandara
Updated:
Sunday at 3:05 AM
Power Lifting Lever Belt
SkullVamp
Updated:
Jun 13, 2026
Ad icon
port.lk Domain for sale
Lankan-Tech
Updated:
Jun 13, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
ElaKiri Programmer's Club
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="MihiCherub" data-source="post: 17883402" data-attributes="member: 238676"><p><span style="font-size: 12px">බලන්න මේක හරියනවද කියල.</span></p><p></p><p><span style="font-size: 12px">Skaters Class</span></p><p></p><p>[CODE]import java.util.Arrays;</p><p>import java.util.Objects;</p><p></p><p>/**</p><p> *</p><p> * @author MihiCherub</p><p> */</p><p>public class Skaters {</p><p></p><p> private String name1;</p><p> private String name2;</p><p> private String country;</p><p> private double[] arrTech = new double[8];</p><p> private double[] arrPerf = new double[8];</p><p> private double score;</p><p></p><p> public Skaters() {</p><p> }</p><p></p><p> public String getName1() {</p><p> return name1;</p><p> }</p><p></p><p> public void setName1(String name1) {</p><p> this.name1 = name1;</p><p> }</p><p></p><p> public String getName2() {</p><p> return name2;</p><p> }</p><p></p><p> public void setName2(String name2) {</p><p> this.name2 = name2;</p><p> }</p><p></p><p> public String getCountry() {</p><p> return country;</p><p> }</p><p></p><p> public void setCountry(String country) {</p><p> this.country = country;</p><p> }</p><p></p><p> public double[] getArrTech() {</p><p> return arrTech;</p><p> }</p><p></p><p> public void setArrTech(double[] arrTech) {</p><p> this.arrTech = arrTech;</p><p> }</p><p></p><p> public double[] getArrPerf() {</p><p> return arrPerf;</p><p> }</p><p></p><p> public void setArrPerf(double[] arrArt) {</p><p> this.arrPerf = arrArt;</p><p> }</p><p></p><p> public double getScore() {</p><p> return score;</p><p> }</p><p></p><p> public void setScore(double score) {</p><p> this.score = score;</p><p> }</p><p></p><p> @Override</p><p> public boolean equals(Object object) {</p><p> if (object == null) {</p><p> return false;</p><p> }</p><p> if (getClass() != object.getClass()) {</p><p> return false;</p><p> }</p><p> final Skaters other = (Skaters) object;</p><p> return this.hashCode() == other.hashCode();</p><p> }</p><p></p><p> @Override</p><p> public int hashCode() {</p><p> int hash = 7;</p><p> hash = 71 * hash + Objects.hashCode(this.name1);</p><p> hash = 71 * hash + Objects.hashCode(this.name2);</p><p> hash = 71 * hash + Objects.hashCode(this.country);</p><p> hash = 71 * hash + Arrays.hashCode(this.arrTech);</p><p> hash = 71 * hash + Arrays.hashCode(this.arrPerf);</p><p> hash = 71 * hash + (int) (Double.doubleToLongBits(this.score) ^ (Double.doubleToLongBits(this.score) >>> 32));</p><p> return hash;</p><p> }</p><p>}[/CODE]<span style="font-size: 12px"></span></p><p><span style="font-size: 12px">SkaterRecords Class</span></p><p></p><p>[CODE]import java.util.ArrayList;</p><p>import java.util.List;</p><p>import java.util.Objects;</p><p></p><p>/**</p><p> *</p><p> * @author MihiCherub</p><p> */</p><p>public class SkaterRecords {</p><p></p><p> private final List<Skaters> list;</p><p></p><p> public SkaterRecords() {</p><p> list = new ArrayList<Skaters>();</p><p> }</p><p></p><p> public boolean addRecord(Skaters skaters) {</p><p> return list.add(skaters);</p><p> }</p><p></p><p> public int getTotalRecords() {</p><p> return list.size();</p><p> }</p><p></p><p> public void removeAllFrom(int index) {</p><p> //Captures the beginning of where u specify 'index' to the end and clears it </p><p> list.subList(index, list.size()).clear();</p><p> }</p><p></p><p> public void removeAllUpto(int index) {</p><p> //Captures the beginning '0' up to where u specify 'index' and clears it </p><p> list.subList(0, index).clear();</p><p></p><p> }</p><p></p><p> public void printRecord() {</p><p> for (Skaters skater : list) {</p><p> System.out.println("Name1: " + skater.getName1());</p><p> System.out.println("Name2: " + skater.getName2());</p><p> System.out.println("Country: " + skater.getCountry());</p><p></p><p> double[] arrTech = skater.getArrTech();</p><p> for (double value : arrTech) {</p><p> System.out.print(value + " ");</p><p> }</p><p> System.out.println("");</p><p></p><p> double[] arrPerf = skater.getArrPerf();</p><p> for (double value : arrPerf) {</p><p> System.out.print(value + " ");</p><p> }</p><p> System.out.println("");</p><p></p><p> System.out.println("Score: " + skater.getScore());</p><p> System.out.println("");</p><p> }</p><p> }</p><p></p><p> public Skaters getWinner() {</p><p> double max = 0;</p><p> Skaters winner = null;</p><p> for (Skaters skater : list) {</p><p> if (max < skater.getScore()) {</p><p> max = skater.getScore();</p><p> winner = skater;</p><p> }</p><p> }</p><p> return winner;</p><p> }</p><p></p><p> @Override</p><p> public boolean equals(Object object) {</p><p> if (object == null) {</p><p> return false;</p><p> }</p><p> if (getClass() != object.getClass()) {</p><p> return false;</p><p> }</p><p> final SkaterRecords other = (SkaterRecords) object;</p><p> return this.hashCode() == other.hashCode();</p><p> }</p><p></p><p> @Override</p><p> public int hashCode() {</p><p> int hash = 7;</p><p> hash = 71 * hash + Objects.hashCode(this.list);</p><p> return hash;</p><p> }</p><p></p><p>}[/CODE]<span style="font-size: 12px"></span></p><p><span style="font-size: 12px">Main Class</span></p><p>[CODE]</p><p>import java.io.File;</p><p>import java.io.FileNotFoundException;</p><p>import java.util.Scanner;</p><p></p><p>/**</p><p> *</p><p> * @author MihiCherub</p><p> */</p><p>public class TestSkaters {</p><p></p><p> private static SkaterRecords skaterRecords;</p><p></p><p> public static void main(String[] args) throws FileNotFoundException {</p><p> skaterRecords = new SkaterRecords();</p><p> readFile();</p><p></p><p> skaterRecords.printRecord();</p><p> Skaters winner = skaterRecords.getWinner();</p><p> System.out.println("Medal Winners :");</p><p> System.out.println("Name1: " + winner.getName1());</p><p> System.out.println("Name2: " + winner.getName2());</p><p> System.out.println("Country: " + winner.getCountry());</p><p> System.out.println("Score: " + winner.getScore());</p><p> }</p><p></p><p> private static void readFile() throws FileNotFoundException {</p><p> File file = new File("Pairs.txt");</p><p> Scanner input;</p><p> if (file.exists()) { // FileNotFoundException Handle </p><p> input = new Scanner(file);</p><p> while (input.hasNext()) {</p><p></p><p> Skaters skater = new Skaters();</p><p> skater.setName1(input.nextLine());</p><p> skater.setName2(input.nextLine());</p><p> skater.setCountry(input.nextLine());</p><p></p><p> double sum = 0;</p><p></p><p> final double tech[] = new double[8];</p><p> for (int i = 0; i < 8; i++) {</p><p> tech[i] = input.nextDouble();</p><p> sum += tech[i];</p><p> }</p><p> skater.setArrTech(tech);</p><p></p><p> final double perf[] = new double[8];</p><p> for (int i = 0; i < 8; i++) {</p><p> perf[i] = input.nextDouble();</p><p> sum += perf[i];</p><p> }</p><p> skater.setArrPerf(perf);</p><p> skater.setScore(sum / 2);</p><p> skaterRecords.addRecord(skater);</p><p></p><p> if (input.hasNextLine()) {</p><p> input.nextLine();</p><p> }</p><p> }</p><p> try {</p><p> } finally {</p><p> input.close();</p><p> }</p><p> }</p><p> }</p><p>}[/CODE]<span style="font-size: 12px"></span></p><p><span style="font-size: 12px">අවුලක් තියෙනව නම් අහන්න.</span> <img src="/styles/default/xenforo/smilies/default/D.gif" class="smilie" loading="lazy" alt=":D" title="Big grin :D" data-shortname=":D" /></p></blockquote><p></p>
[QUOTE="MihiCherub, post: 17883402, member: 238676"] [SIZE=3]බලන්න මේක හරියනවද කියල.[/SIZE] [SIZE=3]Skaters Class[/SIZE] [CODE]import java.util.Arrays; import java.util.Objects; /** * * @author MihiCherub */ public class Skaters { private String name1; private String name2; private String country; private double[] arrTech = new double[8]; private double[] arrPerf = new double[8]; private double score; public Skaters() { } public String getName1() { return name1; } public void setName1(String name1) { this.name1 = name1; } public String getName2() { return name2; } public void setName2(String name2) { this.name2 = name2; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public double[] getArrTech() { return arrTech; } public void setArrTech(double[] arrTech) { this.arrTech = arrTech; } public double[] getArrPerf() { return arrPerf; } public void setArrPerf(double[] arrArt) { this.arrPerf = arrArt; } public double getScore() { return score; } public void setScore(double score) { this.score = score; } @Override public boolean equals(Object object) { if (object == null) { return false; } if (getClass() != object.getClass()) { return false; } final Skaters other = (Skaters) object; return this.hashCode() == other.hashCode(); } @Override public int hashCode() { int hash = 7; hash = 71 * hash + Objects.hashCode(this.name1); hash = 71 * hash + Objects.hashCode(this.name2); hash = 71 * hash + Objects.hashCode(this.country); hash = 71 * hash + Arrays.hashCode(this.arrTech); hash = 71 * hash + Arrays.hashCode(this.arrPerf); hash = 71 * hash + (int) (Double.doubleToLongBits(this.score) ^ (Double.doubleToLongBits(this.score) >>> 32)); return hash; } }[/CODE][SIZE=3] SkaterRecords Class[/SIZE] [CODE]import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * * @author MihiCherub */ public class SkaterRecords { private final List<Skaters> list; public SkaterRecords() { list = new ArrayList<Skaters>(); } public boolean addRecord(Skaters skaters) { return list.add(skaters); } public int getTotalRecords() { return list.size(); } public void removeAllFrom(int index) { //Captures the beginning of where u specify 'index' to the end and clears it list.subList(index, list.size()).clear(); } public void removeAllUpto(int index) { //Captures the beginning '0' up to where u specify 'index' and clears it list.subList(0, index).clear(); } public void printRecord() { for (Skaters skater : list) { System.out.println("Name1: " + skater.getName1()); System.out.println("Name2: " + skater.getName2()); System.out.println("Country: " + skater.getCountry()); double[] arrTech = skater.getArrTech(); for (double value : arrTech) { System.out.print(value + " "); } System.out.println(""); double[] arrPerf = skater.getArrPerf(); for (double value : arrPerf) { System.out.print(value + " "); } System.out.println(""); System.out.println("Score: " + skater.getScore()); System.out.println(""); } } public Skaters getWinner() { double max = 0; Skaters winner = null; for (Skaters skater : list) { if (max < skater.getScore()) { max = skater.getScore(); winner = skater; } } return winner; } @Override public boolean equals(Object object) { if (object == null) { return false; } if (getClass() != object.getClass()) { return false; } final SkaterRecords other = (SkaterRecords) object; return this.hashCode() == other.hashCode(); } @Override public int hashCode() { int hash = 7; hash = 71 * hash + Objects.hashCode(this.list); return hash; } }[/CODE][SIZE=3] Main Class[/SIZE] [CODE] import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; /** * * @author MihiCherub */ public class TestSkaters { private static SkaterRecords skaterRecords; public static void main(String[] args) throws FileNotFoundException { skaterRecords = new SkaterRecords(); readFile(); skaterRecords.printRecord(); Skaters winner = skaterRecords.getWinner(); System.out.println("Medal Winners :"); System.out.println("Name1: " + winner.getName1()); System.out.println("Name2: " + winner.getName2()); System.out.println("Country: " + winner.getCountry()); System.out.println("Score: " + winner.getScore()); } private static void readFile() throws FileNotFoundException { File file = new File("Pairs.txt"); Scanner input; if (file.exists()) { // FileNotFoundException Handle input = new Scanner(file); while (input.hasNext()) { Skaters skater = new Skaters(); skater.setName1(input.nextLine()); skater.setName2(input.nextLine()); skater.setCountry(input.nextLine()); double sum = 0; final double tech[] = new double[8]; for (int i = 0; i < 8; i++) { tech[i] = input.nextDouble(); sum += tech[i]; } skater.setArrTech(tech); final double perf[] = new double[8]; for (int i = 0; i < 8; i++) { perf[i] = input.nextDouble(); sum += perf[i]; } skater.setArrPerf(perf); skater.setScore(sum / 2); skaterRecords.addRecord(skater); if (input.hasNextLine()) { input.nextLine(); } } try { } finally { input.close(); } } } }[/CODE][SIZE=3] අවුලක් තියෙනව නම් අහන්න.[/SIZE] :D [/QUOTE]
Insert quotes…
Verification
Awruddata maasa keeyada?
Post reply
Top
Bottom