• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 17:34
CET 22:34
KST 06:34
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro24 Preview Pt1: New Chaos0Team Liquid Map Contest #22 - Presented by Monster Energy7ByuL: The Forgotten Master of ZvT30Behind the Blue - Team Liquid History Book19Clem wins HomeStory Cup 289
Community News
Weekly Cups (March 16-22): herO doubles, Cure surprises3Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool44Weekly Cups (March 9-15): herO, Clem, ByuN win42026 KungFu Cup Announcement6BGE Stara Zagora 2026 cancelled12
StarCraft 2
General
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Weekly Cups (March 16-22): herO doubles, Cure surprises Weekly Cups (August 25-31): Clem's Last Straw? Team Liquid Map Contest #22 - Presented by Monster Energy What mix of new & old maps do you want in the next ladder pool? (SC2)
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament World University TeamLeague (500$+) | Signups Open RSL Season 4 announced for March-April WardiTV Team League Season 10 KSL Week 87
Strategy
Custom Maps
Publishing has been re-enabled! [Feb 24th 2026]
External Content
The PondCast: SC2 News & Results Mutation # 518 Radiation Zone Mutation # 517 Distant Threat Mutation # 516 Specter of Death
Brood War
General
mca64Launcher - New Version with StarCraft: Remast BGH Auto Balance -> http://bghmmr.eu/ ASL21 General Discussion Soulkey's decision to leave C9 JaeDong's form before ASL
Tourneys
[ASL21] Ro24 Group B 2026 Changsha Offline Cup [ASL21] Ro24 Group A ASL Season 21 LIVESTREAM with English Commentary
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Soma's 9 hatch build from ASL Game 2
Other Games
General Games
Nintendo Switch Thread General RTS Discussion Thread Stormgate/Frost Giant Megathread Path of Exile Dawn of War IV
Dota 2
Official 'what is Dota anymore' discussion The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Five o'clock TL Mafia Mafia Game Mode Feedback/Ideas Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine YouTube Thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
[Req][Books] Good Fantasy/SciFi books Movie Discussion! [Manga] One Piece
Sports
2024 - 2026 Football Thread Cricket [SPORT] Formula 1 Discussion Tokyo Olympics 2021 Thread General nutrition recommendations
World Cup 2022
Tech Support
Laptop capable of using Photoshop Lightroom?
TL Community
The Automated Ban List
Blogs
Funny Nicknames
LUCKY_NOOB
Money Laundering In Video Ga…
TrAiDoS
Iranian anarchists: organize…
XenOsky
FS++
Kraekkling
Shocked by a laser…
Spydermine0240
Unintentional protectionism…
Uldridge
ASL S21 English Commentary…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1565 users

The Big Programming Thread - Page 241

Forum Index > General Forum
Post a Reply
Prev 1 239 240 241 242 243 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
SevenShots
Profile Joined November 2011
Germany84 Posts
February 09 2013 17:21 GMT
#4801
On February 10 2013 01:45 CptCutter wrote:
I generally tend to prefer C++ even with its annoying error messages because it gives far more control over the programming. C# is nice too.


That's the thing about C/C++:

The advantage: You have way more control.
The disadvantage: You have way more control.

=)
Savi[wOk]
Profile Blog Joined August 2012
United States81 Posts
February 11 2013 01:14 GMT
#4802
The Dueling Network
Runescape
Games you don't have to download and are able to play on the browser are called
Browser Based games.

Can someone recommend me some things I may need to learn in order to be able to do this?
Lets play starcraft
tofucake
Profile Blog Joined October 2009
Hyrule19197 Posts
February 11 2013 01:27 GMT
#4803
Javascript.
Liquipediaasante sana squash banana
Craton
Profile Blog Joined December 2009
United States17281 Posts
February 11 2013 01:53 GMT
#4804
Pretty much any web technology. Flash is a big player in browser-based games.
twitch.tv/cratonz
Kentor *
Profile Blog Joined December 2007
United States5784 Posts
Last Edited: 2013-02-11 02:14:42
February 11 2013 02:06 GMT
#4805
On February 11 2013 10:14 Savi[wOk] wrote:
The Dueling Network
Runescape
Games you don't have to download and are able to play on the browser are called
Browser Based games.

Can someone recommend me some things I may need to learn in order to be able to do this?

runescape is a java applet

you have to download java to play it.
CptCutter
Profile Joined September 2010
United Kingdom370 Posts
February 11 2013 13:40 GMT
#4806
On February 11 2013 11:06 Kentor wrote:
Show nested quote +
On February 11 2013 10:14 Savi[wOk] wrote:
The Dueling Network
Runescape
Games you don't have to download and are able to play on the browser are called
Browser Based games.

Can someone recommend me some things I may need to learn in order to be able to do this?

runescape is a java applet

you have to download java to play it.


Runescape is actually written with an inhouse version of Java. Jagex will be one of the places i will applying to for internship ^_^
3FFA
Profile Blog Joined February 2010
United States3931 Posts
Last Edited: 2013-02-11 13:56:40
February 11 2013 13:56 GMT
#4807
In the following code: how would I use C to get user input for my string? My teacher said it was awkward and wouldn't teach us it. =/

Note: Code is made to count the number of vowels in a sentence.
+ Show Spoiler +

#include <stdio.h>

int main(int argc, const char * argv[])
{
//declare variables
int a = 0;
int e = 0;
int i = 0;
int o = 0;
int u = 0;

//display string's sentence
char* S1 = "You are cool";
printf("original string is: %s\n", S1);

//count the vowels
for (int v = 0; v < strlen(S1); v++)
{
if (S1[v] == 'a' || S1[v] == 'A')
{
a++;
}

else if (S1[v] == 'e' || S1[v] == 'E')
{
e++;
}

else if (S1[v] == 'i' || S1[v] == 'I')
{
i++;
}

else if (S1[v] == 'o' || S1[v] == 'O')
{
o++;
}

else if (S1[v] == 'u' || S1[v] == 'U')
{
u++;
}
}

//output result
printf("there are %i 'a' vowels \n", a);
printf("there are %i 'e' vowels \n", e);
printf("there are %i 'i' vowels \n", e);
printf("there are %i 'o' vowels \n", o);
printf("there are %i 'u' vowels \n", u);

return 0;
}
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
February 11 2013 14:04 GMT
#4808
On February 11 2013 10:27 tofucake wrote:
Javascript.

This. It used to be Flash or Java, but nowadays and especially from here on out, both technologies are becoming obsolete for browser games because they require plugins which leads to security risk... and flash obviously has the problem of being proprietary.

Javascript with HTML5 let's you do pretty sick stuff, especially in modern browsers which use sufficiently fast javascript engines. At the moment it's only really viable for 2D, but there is a standard for 3D in the works as well. A few years from now, you'll probably be hard pressed to find new browser games made in anything other than javascript.
tec27
Profile Blog Joined June 2004
United States3702 Posts
February 11 2013 16:04 GMT
#4809
On February 11 2013 23:04 Tobberoth wrote:
Show nested quote +
On February 11 2013 10:27 tofucake wrote:
Javascript.

This. It used to be Flash or Java, but nowadays and especially from here on out, both technologies are becoming obsolete for browser games because they require plugins which leads to security risk... and flash obviously has the problem of being proprietary.

Javascript with HTML5 let's you do pretty sick stuff, especially in modern browsers which use sufficiently fast javascript engines. At the moment it's only really viable for 2D, but there is a standard for 3D in the works as well. A few years from now, you'll probably be hard pressed to find new browser games made in anything other than javascript.

3D is fairly viable at this point as well. I'm sure gamers have an even lower percentage of IE8 than the world as a whole.

Here's a pretty cool recent project from some of the nodejs guys: http://voxeljs.com/
Can you jam with the console cowboys in cyberspace?
Samsa
Profile Joined April 2009
Germany72 Posts
Last Edited: 2013-02-11 17:06:45
February 11 2013 17:06 GMT
#4810
Hey guys!

I got a C# MVC Web Application running, with a problem (i guess it's a missunderstanding on my side).
There is a View wich lists a List of Items in a beforehand specified Room, including a form with one textbox. In this Textbox you can put a identification wich relates to one item.
So my idea was the following:
you chose a room, an get the list of items in that room. if you input a identification the controller changes the state of the identified item and returns the model back to the same view. (the model is not in the db context, and I only change values directly)
The problem i got:
1. he remembers the input identification even if i set the value of the model to string.Empty
2. only remembers the last state-change (aka on a second input identifier, the first one goes back to his original state and the newly input one changes)

I'm not that familiar with all the c# mvc concepts, so my latest guess is: i need to bind the model to the database context and set the EntityState.Modified. But i do not want the model in the DB, also I only want to save the changes once to the DB.

below are the models (simplified, cause they got some other unrelated properties)
the models in the database context:

public class Room
{
public Guid RoomID { get; set; }
...
public virtual ICollection<Items> Items { get; set; }
}
public class Items
{
public Guid ItemID { get; set; }
...
public Guid RoomID { get; set; }
public virtual Room Room { get; set; }
}
}


and here the models i just use for the views:

public class RoomScan { get; set; }
{
public ItemState ICollection<Items> Items { get; set; }
...
}
public class ItemState
{
public Item Item { get; set; }
public bool Active { get; set; }
}


I hope you understand my problem!
and any help is appreciated
delHospital
Profile Blog Joined December 2010
Poland261 Posts
February 11 2013 18:05 GMT
#4811
On February 11 2013 22:56 3FFA wrote:
In the following code: how would I use C to get user input for my string? My teacher said it was awkward and wouldn't teach us it. =/

Note: Code is made to count the number of vowels in a sentence.
+ Show Spoiler +

#include <stdio.h>

int main(int argc, const char * argv[]
{
//declare variables
int a = 0;
int e = 0;
int i = 0;
int o = 0;
int u = 0;

//display string's sentence
char* S1 = "You are cool";
printf("original string is: %s\n", S1);

//count the vowels
for (int v = 0; v < strlen(S1); v++)
{
if (S1[v] == 'a' || S1[v] == 'A')
{
a++;
}

else if (S1[v] == 'e' || S1[v] == 'E')
{
e++;
}

else if (S1[v] == 'i' || S1[v] == 'I')
{
i++;
}

else if (S1[v] == 'o' || S1[v] == 'O')
{
o++;
}

else if (S1[v] == 'u' || S1[v] == 'U')
{
u++;
}
}

//output result
printf("there are %i 'a' vowels \n", a);
printf("there are %i 'e' vowels \n", e);
printf("there are %i 'i' vowels \n", e);
printf("there are %i 'o' vowels \n", o);
printf("there are %i 'u' vowels \n", u);

return 0;
}

try this (it will read characters until it finds a newline/end-of-file/reaches 99 chars)

char S1[100];
fgets(S1, 100, stdin);
CptCutter
Profile Joined September 2010
United Kingdom370 Posts
February 11 2013 19:34 GMT
#4812
On February 12 2013 03:05 delHospital wrote:
Show nested quote +
On February 11 2013 22:56 3FFA wrote:
In the following code: how would I use C to get user input for my string? My teacher said it was awkward and wouldn't teach us it. =/

Note: Code is made to count the number of vowels in a sentence.
+ Show Spoiler +

#include <stdio.h>

int main(int argc, const char * argv[]
{
//declare variables
int a = 0;
int e = 0;
int i = 0;
int o = 0;
int u = 0;

//display string's sentence
char* S1 = "You are cool";
printf("original string is: %s\n", S1);

//count the vowels
for (int v = 0; v < strlen(S1); v++)
{
if (S1[v] == 'a' || S1[v] == 'A')
{
a++;
}

else if (S1[v] == 'e' || S1[v] == 'E')
{
e++;
}

else if (S1[v] == 'i' || S1[v] == 'I')
{
i++;
}

else if (S1[v] == 'o' || S1[v] == 'O')
{
o++;
}

else if (S1[v] == 'u' || S1[v] == 'U')
{
u++;
}
}

//output result
printf("there are %i 'a' vowels \n", a);
printf("there are %i 'e' vowels \n", e);
printf("there are %i 'i' vowels \n", e);
printf("there are %i 'o' vowels \n", o);
printf("there are %i 'u' vowels \n", u);

return 0;
}

try this (it will read characters until it finds a newline/end-of-file/reaches 99 chars)

char S1[100];
fgets(S1, 100, stdin);

or he could just use cin...
delHospital
Profile Blog Joined December 2010
Poland261 Posts
February 11 2013 19:36 GMT
#4813
On February 12 2013 04:34 CptCutter wrote:
Show nested quote +
On February 12 2013 03:05 delHospital wrote:
On February 11 2013 22:56 3FFA wrote:
In the following code: how would I use C to get user input for my string? My teacher said it was awkward and wouldn't teach us it. =/

Note: Code is made to count the number of vowels in a sentence.
+ Show Spoiler +

#include <stdio.h>

int main(int argc, const char * argv[]
{
//declare variables
int a = 0;
int e = 0;
int i = 0;
int o = 0;
int u = 0;

//display string's sentence
char* S1 = "You are cool";
printf("original string is: %s\n", S1);

//count the vowels
for (int v = 0; v < strlen(S1); v++)
{
if (S1[v] == 'a' || S1[v] == 'A')
{
a++;
}

else if (S1[v] == 'e' || S1[v] == 'E')
{
e++;
}

else if (S1[v] == 'i' || S1[v] == 'I')
{
i++;
}

else if (S1[v] == 'o' || S1[v] == 'O')
{
o++;
}

else if (S1[v] == 'u' || S1[v] == 'U')
{
u++;
}
}

//output result
printf("there are %i 'a' vowels \n", a);
printf("there are %i 'e' vowels \n", e);
printf("there are %i 'i' vowels \n", e);
printf("there are %i 'o' vowels \n", o);
printf("there are %i 'u' vowels \n", u);

return 0;
}

try this (it will read characters until it finds a newline/end-of-file/reaches 99 chars)

char S1[100];
fgets(S1, 100, stdin);

or he could just use cin...

no cin in c
3FFA
Profile Blog Joined February 2010
United States3931 Posts
February 11 2013 19:48 GMT
#4814
What does fgets do? :o
"As long as it comes from a pure place and from a honest place, you know, you can write whatever you want."
WindWolf
Profile Blog Joined July 2012
Sweden11767 Posts
February 11 2013 19:51 GMT
#4815
Just a little question for some more experienced C++ programmers. Do you think it is ok to use typedef to shorten types that gets really long?

In the project I'm working on, I work with std::map<std::string, std::vector<sf::Sound*>>, which I have typedefed as soundMap
EZ4ENCE
delHospital
Profile Blog Joined December 2010
Poland261 Posts
Last Edited: 2013-02-11 20:04:23
February 11 2013 19:59 GMT
#4816
On February 12 2013 04:48 3FFA wrote:
What does fgets do? :o

Reads a line of text from a file.
First argument = where to store the input
Second argument = the maximum number of characters (bytes) to read, most often the size of the buffer given in the first argument
Third argument = file to read from, stdin = standard input, if you're running your program from a terminal, it will be what the user types into it

Also, if you were writing a serious program, it would be a good idea to check the return value. If it's NULL, then either end-of-file was reached or an error occured.
Hitch-22
Profile Blog Joined February 2013
Canada753 Posts
Last Edited: 2013-02-11 23:19:05
February 11 2013 23:07 GMT
#4817
Course.java (this allows the creation of 'courses')
+ Show Spoiler +
abstract public class Course implements Comparable
{	private int credit;
private static String grade;
private String title;

public Course(int c, String g, String t)
{ credit = c;
grade = g;
title = t;
}

/** @param Compares courses based on their total grade points
*/
public int compareTo(Comparable other)
{ int result = 0;

if(getPoints() > ((Course)other).getPoints())
{
result = 1;
}
else if(getPoints() < ((Course)other).getPoints())
{
result = -1;
}

return result;
}

/** @return Retrieves the credit hours.
*/
public int getCreditHrs()
{ return credit;
}

/** @return Retrieves the letter grade.
*/
public String getGrade()
{ return grade;
}

/** @return Retrieves the course title.
*/
public String getTitle()
{ return title;
}

/** @return Determines the total number of grade points earned in this course
*/
public abstract double getPoints();

/** @param Converts a letter grade to the equivalent point value
*/
public static double gradeConvert(String letterGrade)
{ double i = 0;

if(grade.equals("A+"))
{ i = 4.3;
}
else if(grade.equals("A"))
{ i = 4.0;
}
else if(grade.equals("A-"))
{ i = 3.7;
}
else if(grade.equals("B+"))
{ i = 3.3;
}
else if(grade.equals("B"))
{ i = 3.0 ;
}
else if(grade.equals("B-"))
{ i = 2.7 ;
}
else if(grade.equals("C+"))
{ i = 2.3 ;
}
else if(grade.equals("C"))
{ i = 2.0;
}
else if(grade.equals("D"))
{ i = 1.0;
}
else if(grade.equals("F"))
{ i = 0.0;
}
else if(grade.equals("WF"))
{ i = 0.0;
}

return i;

}

/** @return Creates and returns a textual string containing the course title, letter grade, and total grade points earned.
*/
public String toString()
{ String result = "";

result = getTitle() + " " + getGrade() + " " + "points " + getPoints();


return result;

}


}


Student.java (This creates a 'student')
+ Show Spoiler +

public class Student
{ private String firstName;
private String lastName;

// Companion Variable
private int arrCouCompanion;
Course arrayCourses[] = new Course[15];

public Student(String firstNameIn, String lastNameIn)
{ firstName = firstNameIn;
lastName = lastNameIn;
arrCouCompanion = 0;
}

public void addCourse(String titleInput,
int creditInput,
String letterGradeInput,
int courseTypeInput)
{ if(courseTypeInput == 1)
{ arrayCourses[arrCouCompanion] = new CSInfoCore(creditInput,
letterGradeInput,
titleInput);
arrCouCompanion++;
}
else if(courseTypeInput == 2)
{ arrayCourses[arrCouCompanion] = new MathCore(creditInput,
letterGradeInput,
titleInput);
arrCouCompanion++;
}
else if(courseTypeInput == 3)
{ arrayCourses[arrCouCompanion] = new Breadth(creditInput,
letterGradeInput,
titleInput);

arrCouCompanion++;
}
else if(courseTypeInput == 4)
{ arrayCourses[arrCouCompanion] = new Electives(creditInput,
letterGradeInput,
titleInput);
arrCouCompanion++;
}
else
{ System.out.println("Please re-enter a valid input");
}

}

public void reOrder();
{ int min;
Course temp;

for (int index = 0; index < arrayCourses.length-1; index++)
{ min = index;
for (int scan = index+1; scan < arrCouCompanion; scan++)
{ if (arrayCourses[scan].compareTo(arrayCourses[min]) < 0)
{min = scan;

// Swap the values
temp = arrayCourses[min];
arrayCourses[min] = arrayCourses[index];
arrayCourses[index] = temp;
}
}
}
}

public String searchCourse(String tookCourse )
{ String result = "Course ";
int i = 0;
boolean isTrue = false;

for (i = 0;i < arrayCourses.length-1 && !isTrue;i++)
{ if(tookCourse.equals(arrayCourses[i].getTitle()))
{ isTrue = true;
}
}

if(isTrue)
{ result += arrayCourses[i];
}
else
{ result += tookCourse + " not found";
}

return result;
}

public String toString()
{ String result = "";
result = firstName + " " + lastName + "\n"
+ "Courses:\n\t";
for(int i = 0;i < arrayCourses.length-1;i++)
{ result += arrayCourses[i] + "\n";
}
return result;
}

}


CourseDriver.java (This is the testing class)
+ Show Spoiler +


import java.util.Scanner;

public class CourseDriver
{ public static void main(String[] args)
{ Scanner scan = new Scanner(System.in);
String firstName = scan.next();
String lastName = scan.next();

Student student = new Student(firstName, lastName);
String titleIn = scan.next();

while(!titleIn.equals("end"))
{ int creditIn = scan.nextInt();
String grade = scan.next();
int courseTypeInputIn = scan.nextInt();
student.addCourse(titleIn, creditIn, grade, courseTypeInputIn);
titleIn = scan.next();
}
System.out.println("this shit be un-sorted " + student);

student.reOrder();
System.out.println("This shit be sorted nigga " + student);

titleIn = scan.next();

while(!titleIn.equals("end"))
{ System.out.println(student.searchCourse(titleIn));
titleIn = scan.next();
}

}
}[code][/spoiler]

CSInfoCore.java (This allows the overriding of abstract class getPoints())
[spoiler]
[code]
public abstract class CSInfoCore extends Course
{ public CSInfoCore(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = getCreditHrs()*gradeConvert("grade");
return grade;
}
}


MathCore.java (This allows the overriding of abstract class getPoints())
+ Show Spoiler +


public abstract class MathCore extends Course
{ public MathCore(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = 1.5*getCreditHrs()*gradeConvert("grade");
return grade;
}
}


Breadth.java (This allows the overriding of abstract class getPoints())
+ Show Spoiler +


public abstract class Breadth extends Course
{ public Breadth(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = 1.2*getCreditHrs()*gradeConvert("grade");
return grade;
}
}


Electives.java (This allows the overriding of abstract class getPoints())
+ Show Spoiler +


public abstract class Electives extends Course
{ public Electives(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = 0.9*getCreditHrs()*gradeConvert("grade");
return grade;
}
}


My error is this:

error: CSInfoCore is abstract; cannot be instantiated
arrayCourses[arrCouCompanion] = new CSInfoCore(creditInput, ...)

This follows for the next 4 instantiated sections (one after another).

I can't remove the abstraction, however, because then I get the error (Speaking of classes CSInfoCore through Electives) that you can't edit an abstract method without an abstract class.

THANKS! (This is due tonight, put a lot of time in it, if anyone can put in some good ideas or see where I screwed up that'd be great!)
"We all let our sword do the talking for us once in awhile I guess" - Bregor, the legendary critical striker and critical misser who triple crits 2 horses with 1 arrow but lands 3 1's in a row
CecilSunkure
Profile Blog Joined May 2010
United States2829 Posts
February 11 2013 23:44 GMT
#4818
On February 12 2013 04:51 WindWolf wrote:
Just a little question for some more experienced C++ programmers. Do you think it is ok to use typedef to shorten types that gets really long?

In the project I'm working on, I work with std::map<std::string, std::vector<sf::Sound*>>, which I have typedefed as soundMap

Yes. Usually typedefs like this go inside of a class definition so you can do: SoundManager::soundMap.
delHospital
Profile Blog Joined December 2010
Poland261 Posts
Last Edited: 2013-02-12 01:15:27
February 12 2013 01:10 GMT
#4819
On February 12 2013 08:07 Hitch-22 wrote:
Course.java (this allows the creation of 'courses')
+ Show Spoiler +
abstract public class Course implements Comparable
{	private int credit;
private static String grade;
private String title;

public Course(int c, String g, String t)
{ credit = c;
grade = g;
title = t;
}

/** @param Compares courses based on their total grade points
*/
public int compareTo(Comparable other)
{ int result = 0;

if(getPoints() > ((Course)other).getPoints())
{
result = 1;
}
else if(getPoints() < ((Course)other).getPoints())
{
result = -1;
}

return result;
}

/** @return Retrieves the credit hours.
*/
public int getCreditHrs()
{ return credit;
}

/** @return Retrieves the letter grade.
*/
public String getGrade()
{ return grade;
}

/** @return Retrieves the course title.
*/
public String getTitle()
{ return title;
}

/** @return Determines the total number of grade points earned in this course
*/
public abstract double getPoints();

/** @param Converts a letter grade to the equivalent point value
*/
public static double gradeConvert(String letterGrade)
{ double i = 0;

if(grade.equals("A+"))
{ i = 4.3;
}
else if(grade.equals("A"))
{ i = 4.0;
}
else if(grade.equals("A-"))
{ i = 3.7;
}
else if(grade.equals("B+"))
{ i = 3.3;
}
else if(grade.equals("B"))
{ i = 3.0 ;
}
else if(grade.equals("B-"))
{ i = 2.7 ;
}
else if(grade.equals("C+"))
{ i = 2.3 ;
}
else if(grade.equals("C"))
{ i = 2.0;
}
else if(grade.equals("D"))
{ i = 1.0;
}
else if(grade.equals("F"))
{ i = 0.0;
}
else if(grade.equals("WF"))
{ i = 0.0;
}

return i;

}

/** @return Creates and returns a textual string containing the course title, letter grade, and total grade points earned.
*/
public String toString()
{ String result = "";

result = getTitle() + " " + getGrade() + " " + "points " + getPoints();


return result;

}


}


Student.java (This creates a 'student')
+ Show Spoiler +

public class Student
{ private String firstName;
private String lastName;

// Companion Variable
private int arrCouCompanion;
Course arrayCourses[] = new Course[15];

public Student(String firstNameIn, String lastNameIn)
{ firstName = firstNameIn;
lastName = lastNameIn;
arrCouCompanion = 0;
}

public void addCourse(String titleInput,
int creditInput,
String letterGradeInput,
int courseTypeInput)
{ if(courseTypeInput == 1)
{ arrayCourses[arrCouCompanion] = new CSInfoCore(creditInput,
letterGradeInput,
titleInput);
arrCouCompanion++;
}
else if(courseTypeInput == 2)
{ arrayCourses[arrCouCompanion] = new MathCore(creditInput,
letterGradeInput,
titleInput);
arrCouCompanion++;
}
else if(courseTypeInput == 3)
{ arrayCourses[arrCouCompanion] = new Breadth(creditInput,
letterGradeInput,
titleInput);

arrCouCompanion++;
}
else if(courseTypeInput == 4)
{ arrayCourses[arrCouCompanion] = new Electives(creditInput,
letterGradeInput,
titleInput);
arrCouCompanion++;
}
else
{ System.out.println("Please re-enter a valid input");
}

}

public void reOrder();
{ int min;
Course temp;

for (int index = 0; index < arrayCourses.length-1; index++)
{ min = index;
for (int scan = index+1; scan < arrCouCompanion; scan++)
{ if (arrayCourses[scan].compareTo(arrayCourses[min] < 0)
{min = scan;

// Swap the values
temp = arrayCourses[min];
arrayCourses[min] = arrayCourses[index];
arrayCourses[index] = temp;
}
}
}
}

public String searchCourse(String tookCourse )
{ String result = "Course ";
int i = 0;
boolean isTrue = false;

for (i = 0;i < arrayCourses.length-1 && !isTrue;i++)
{ if(tookCourse.equals(arrayCourses[i].getTitle()))
{ isTrue = true;
}
}

if(isTrue)
{ result += arrayCourses[i];
}
else
{ result += tookCourse + " not found";
}

return result;
}

public String toString()
{ String result = "";
result = firstName + " " + lastName + "\n"
+ "Courses:\n\t";
for(int i = 0;i < arrayCourses.length-1;i++)
{ result += arrayCourses[i] + "\n";
}
return result;
}

}


CourseDriver.java (This is the testing class)
+ Show Spoiler +


import java.util.Scanner;

public class CourseDriver
{ public static void main(String[] args)
{ Scanner scan = new Scanner(System.in);
String firstName = scan.next();
String lastName = scan.next();

Student student = new Student(firstName, lastName);
String titleIn = scan.next();

while(!titleIn.equals("end"))
{ int creditIn = scan.nextInt();
String grade = scan.next();
int courseTypeInputIn = scan.nextInt();
student.addCourse(titleIn, creditIn, grade, courseTypeInputIn);
titleIn = scan.next();
}
System.out.println("this shit be un-sorted " + student);

student.reOrder();
System.out.println("This shit be sorted nigga " + student);

titleIn = scan.next();

while(!titleIn.equals("end"))
{ System.out.println(student.searchCourse(titleIn));
titleIn = scan.next();
}

}
}[code][/spoiler]

CSInfoCore.java (This allows the overriding of abstract class getPoints())
[spoiler]
[code]
public abstract class CSInfoCore extends Course
{ public CSInfoCore(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = getCreditHrs()*gradeConvert("grade");
return grade;
}
}


MathCore.java (This allows the overriding of abstract class getPoints())
+ Show Spoiler +


public abstract class MathCore extends Course
{ public MathCore(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = 1.5*getCreditHrs()*gradeConvert("grade");
return grade;
}
}


Breadth.java (This allows the overriding of abstract class getPoints())
+ Show Spoiler +


public abstract class Breadth extends Course
{ public Breadth(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = 1.2*getCreditHrs()*gradeConvert("grade");
return grade;
}
}


Electives.java (This allows the overriding of abstract class getPoints())
+ Show Spoiler +


public abstract class Electives extends Course
{ public Electives(int c, String g, String t)
{ super(c,g,t);
}

public double getPoints()
{ double grade = 0.9*getCreditHrs()*gradeConvert("grade");
return grade;
}
}


My error is this:

error: CSInfoCore is abstract; cannot be instantiated
arrayCourses[arrCouCompanion] = new CSInfoCore(creditInput, ...)

This follows for the next 4 instantiated sections (one after another).

I can't remove the abstraction, however, because then I get the error (Speaking of classes CSInfoCore through Electives) that you can't edit an abstract method without an abstract class.

THANKS! (This is due tonight, put a lot of time in it, if anyone can put in some good ideas or see where I screwed up that'd be great!)

I'm not a Java guru, but it should work if you keep Core abstract and make all other classes non-abstract. There's something wrong with compareTo(), too... casting to Course like that is bad OOP. Also, when asking for help on a forum, try posting a minimal (but complete) amount of code that still doesn't work as you would expect instead of dumping contents of 10 files.

E: sorry, this compareTo thing is fine, I think... I'm just bad with Java
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2013-02-12 01:20:35
February 12 2013 01:19 GMT
#4820
So I have this little problem to solve:

You are in charge of recording marks for a group of students. Input a list of marks. Input ends with 0 (0 itself is not someone's mark). Output the number of students who scored 1) greater than or equal to 85; 2) between 60 and 84; 3) strictly less than 60.


Sample Input
88 71 68 70 59 81 91 42 66 77 83 0


I just need a hint how to get input like this in C. Also, how should I go about storing marks? Is this a dynamic memory (heap) matter? I already know about getchar and scanf, but are they enough? Maybe getchar() and putchar()?

Please don't bother to give me the solution. I just need a little help.

Thanks.
Prev 1 239 240 241 242 243 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 2h 26m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
mouzHeroMarine 617
elazer 219
UpATreeSC 91
StarCraft: Brood War
Shuttle 549
Mini 242
firebathero 121
EffOrt 100
NaDa 9
Dota 2
canceldota139
Counter-Strike
pashabiceps2053
byalli816
Super Smash Bros
C9.Mang0172
Heroes of the Storm
Liquid`Hasu370
Other Games
Grubby2976
FrodaN892
ceh9550
Beastyqt512
shahzam444
ToD206
ViBE40
Organizations
Dota 2
PGL Dota 2 - Main Stream48
StarCraft 2
angryscii 19
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• Hinosc 16
• Reevou 8
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• blackmanpl 51
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift3047
Other Games
• imaqtpie841
• Shiphtur152
Upcoming Events
PiGosaur Cup
2h 26m
Replay Cast
11h 26m
Afreeca Starleague
12h 26m
hero vs YSC
Larva vs Shine
Kung Fu Cup
13h 26m
Replay Cast
1d 2h
KCM Race Survival
1d 11h
The PondCast
1d 12h
WardiTV Team League
1d 14h
OSC
1d 14h
Replay Cast
2 days
[ Show More ]
WardiTV Team League
2 days
RSL Revival
3 days
Cure vs Zoun
herO vs Rogue
WardiTV Team League
3 days
Platinum Heroes Events
3 days
BSL
3 days
RSL Revival
4 days
ByuN vs Maru
MaxPax vs TriGGeR
WardiTV Team League
4 days
BSL
4 days
Replay Cast
5 days
Replay Cast
5 days
Afreeca Starleague
5 days
Light vs Calm
Royal vs Mind
Wardi Open
5 days
Monday Night Weeklies
5 days
OSC
6 days
Sparkling Tuna Cup
6 days
Afreeca Starleague
6 days
Rush vs PianO
Flash vs Speed
Liquipedia Results

Completed

Proleague 2026-03-23
WardiTV Winter 2026
Underdog Cup #3

Ongoing

KCM Race Survival 2026 Season 1
BSL Season 22
CSL Elite League 2026
CSL Season 20: Qualifier 1
ASL Season 21
Acropolis #4 - TS6
RSL Revival: Season 4
Nations Cup 2026
NationLESS Cup
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual

Upcoming

2026 Changsha Offline CUP
CSL Season 20: Qualifier 2
CSL 2026 SPRING (S20)
Acropolis #4
IPSL Spring 2026
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
CCT Season 3 Global Finals
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.