+ 4

Cmon Let See my Awesome Exam and how I wrote my code.....Do you like it?so give me Upvote my friends...

now Here's the code pls Give me Upvotes 10+ if you like my Code My Exam...Says you have the Last names of some Students, their marks and Index numbers of Markbook; and it also says that Negative points are(0....9),,,,,So We must write Code by using only Generics which will print the only Index numbers and Last names of Students who got negative marks;;;; package com.company; public class Main { public static void main(String[] args) { Student <String,Integer,Integer> a = new Student<>(); a.setA("Johnson"); a.setB(15); a.setC(1); Student <String,Integer,Integer> b = new Student<>(); b.setA("Williams"); b.setB(5); b.setC(2); Student <String,Integer,Integer> c = new Student<>(); c.setA("Rose"); c.setB(6); c.setC(3); for (int Negative_Points=0;Negative_Points <=9;Negative_Points++){ if (a.getB()==Negative_Points){ System.out.println(a.getC()+"."+a.getA());} if (b.getB()==Negative_Points) { System.out.println(b.getC()+"."+b.getA());} if (c.getB()==Negative_Points) { System.out.println(c.getC()+"."+c.getA()); } } } } class Student<Type,Type1,Type3> { private Type a; private Type1 b; private Type3 c; public Type getA() { return a; } public void setA(Type a) { this.a = a; } public Type1 getB() { return b; } public void setB(Type1 b) { this.b = b; } public Type3 getC() { return c; } public void setC(Type3 c) { this.c = c; } }

18th Sep 2016, 3:50 PM
Zohrab Alexanian
Zohrab Alexanian - avatar
1 Odpowiedź
0
It's quite messy, should have made student an object with these types. This is bad practice, java is OOP for a reason!
3rd Nov 2016, 7:04 AM
somestuffontheinternet
somestuffontheinternet - avatar