Striker
BAN USERHow about as following -
Student.java
package com.amazon.random.studentList;
public class Student implements Comparable<Student> {
private String name;
private Grade grade;
public Student(){
}
public Student(String name, Grade grade){
this.name = name;
this.grade = grade;
}
public enum Grade {
a,b,c,d;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Grade getGrade() {
return grade;
}
public void setGrade(Grade grade) {
this.grade = grade;
}
@Override
public int compareTo(Student o) {
if(this.getGrade().ordinal() == o.getGrade().ordinal())
return (this.getName().compareTo(o.getName()));
else
return (this.getGrade().ordinal() - o.getGrade().ordinal());
}
}
ListOfStudentsQ.java
package com.amazon.random.studentList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public class ListOfStudentsQ {
private List<Student> studentList;
public ListOfStudentsQ(){
studentList = new LinkedList<Student>();
generateList();
}
public void generateList(){
studentList.add(new Student("q",Student.Grade.b));
studentList.add(new Student("p",Student.Grade.b));
studentList.add(new Student("r",Student.Grade.a));
studentList.add(new Student("s",Student.Grade.c));
Collections.sort(studentList);
}
public void displayList(){
Iterator<Student> iter = studentList.iterator();
while(iter.hasNext()){
System.out.println("Student Name According to Grade: " + iter.next().getName());
}
}
public static void main(String args[]){
ListOfStudentsQ obj = new ListOfStudentsQ();
obj.displayList();
}
}
The number of tiles will be equal to the value "W".
- Striker June 07, 2014Need more details on this. For any value of "W", there will be only one (1) way to do this, as we have all tiles of same dimension (2 x 1).